The prototypes might be milled and/or produced via additive manufacturing (3D printing.) In production the heads are likely formed via stamping. Here's an old video I remember watching as a kid (Unfortunately quite pixelated) of the Robertson screw being manufactured which has a tapered square profile for the bit: https://www.youtube.com/watch?v=Td7GjAMAY7Y (The Acme School of Stuff was awesome for its time and still is.)