That's a big question but to focus on the part where the reeded edge is created you just need to know that a coin blank is compressed on its edge in an upsetting mill to create the raised rim resulting in a planchet. Then the planchet is placed in a collar on the coin press and struck between the obverse and reverse die. The pressure from the strike causes the coin metal to flow into the depressions on the dies and the inner surface of the collar. For the reeded edge design, the inner surface of the collar is engraved with those lines.
Earlier coins, such as the milled 8 reales of the Spanish Empire, were struck without the use of collars. They are rarely perfectly centered and generally not quite round. Their edge designs were imparted when they were passed through a parallel die edging machine, like a Castaing machine, that also upset the edge to create the rim.
The idea of putting reeding or some other design onto the edge of a coin goes back to 1643 when it was first invented by the Royal Mint of France. It was done to prevent an all too common practice of the times known as clipping which was a process where some of the metal was shaved, clipped, or cut off the edge of a coin. And then saved to be sold later by the one doing the clipping. An since most coins were silver and gold back then it was a very profitable practice. The old edge dies looked much different and came in various designs, but the principle was always the same, and in fact it still is today. It was usually done after the coin had already been struck, but it could be done prior to striking as well. In simple terms the edge of the coin, or planchet, was placed into the edge die and then merely rolled along and through it while pressure was being applied to the opposite edge. Centuries ago edge dies like those used on the Spanish reales were typically a straight perpendicular groove at the outer edge of a flat table and the coin was rolled through it. Today edge dies, and yes some mints still use them, can be straight and or curved. This for example is an edge die used by the US Mint on our modern dollar coins. And they are bit bigger than one might think, over a foot long. Typically they are only used in today's world when lettering is desired on the edge of a coin as opposed to reeding. It is simply easier to put letters on the edge of coin this way than it is with collars. But when reeding is desired, even though there is no longer any use or need for it per se, the collar system is employed because it is so much faster and cheaper to do it that way.
If you are ever in the UK you can view the whole process live at the Llantrisant Royal Mint works in South Wales.
Reeds that are straight are formed by the collar die which moves into place at the time the coin is struck and then retracts when the struck coin is ejected. Any other sort of edge decoration is done either using a multi-segment collar that opens and closes around the coin at time of striking or is done after striking. The edge lettering device shown above is for business strike dollar coins, for which lettering is done after striking. For proof coins, a multi-part collar is used. A normal collar die used for anything other than straight reeds would be prone to shearing off the decoration.