Nails are made by pulling a wire thru a set of dies, so the metal has to be somewhat malleable so the wire can take the tremendous pull that it goes thru when it's size gets reduced in the die.
The wire after it has been reduced to the proper size (there are many sizes of course) to make a nail , then the nail is cut to length and the head and point are formed
The head and the nail point are formed at the same time and the head is made from the point material of the nail behind it, so no material is wasted. Again the metal has to be malleable enough so the metal can be forced and deformed into a nail head.
Screws on the other hand are actually cut into screws. The wire is used to make the screw is not near as malleable but the metal is harder. The wire is placed on a machine that cuts the threads into the wire. The threads have to be of harder steel so that the threads of the screw don't deform when the screw is being twisted into wood or metal.
The steel is a harder than the nail, but it still needs to deforms the head to make the phillips head or straight line head.