It's done using very, very small circuits. Integrated circuits started out in the 1960's holding dozens of transistors. Ever since then, the industry has managed to double the number of transistors on a same-sized piece of silicon every two years.
Over 45 years that adds up fast, and now they can put literally billions of transistors on a single piece of silicon about the size of your thumbnail.
That explains CPUs and such, but not drives. Like a record, a harddrive is a matter of pits and grooves. Over the years we have learned how to make the pits even smaller, and pack the grooves even closer together. The most recent technology that allowed us to increase disk size was perpendicular recording which allowed us to put the pit on its end. The next big push might be HAMR.
Not to disagree with you, but rather as a point of interest - hard drive heads are now made using lithographic techniques similar to the way ICs are made - so there is actually a relationship between the two.
But you're right, for hard drive it's not just the size of the head that matters, it's also the recording technique, the composition and manner in which the magnetic layer is laid down on the platter, smoothness of the media, accuracy of the head actuator, etc. etc.