It's fair to say cotter pins became obsolete for a reason, they are less reliable than the cotterless bolt on cranks that replaced them. But they do look stylish, and they won't disappear off the face of the earth anytime soon.
In short, traditional cranks have a hole through them to fit a cotter pin. The spindle has a notch cut out at each end to accommodate the pins, when the pins are in position they hold the cranks in place against the spindle. The pins are an interference fit and also have a threaded end with a washer and nut.
If you tinker a lot with vintage bikes made before the mid 80's, you will encounter them. If you work with them regularly, you will no doubt have a favourite method of removal. For a few years my technique was generous helpings of penetrating oil (Plus Gas works well), then hit with a hammer and punch. A stuck pin could also be pushed out by applying pressure with a bench vice, using a steel socket over the non threaded end of the pin. The space from the socket gives the pin room to pop out. If the pin mushroomed, or was completely seized then I have on occasion had to use a dremel to drill it out. Unfortunately drilling almost always damages the crank, and should be a last resort. If that last resort failed, then it's time to get out the angle grinder otherwise your frame is basically scrap metal.
To fit cotter pins, essentially reverse the original strategy and tap them in while the cranks and spindle are in the correct position, then tighten up the nut. After a few rides then tap and tighten again, then again after 50-100 miles. Don't try and tighten the nut to get the pins to fit more tightly, it will just strip the thread (we've all done it at least once).
Normally, I am an advocate of keeping things simple, but when it comes to cotter pins, that attitude has changed. One summer morning, cycling home from a local trip I decided to take a shortcut. It was a steel frame road bike, and this shortcut involved a small flight of 3 concrete steps, as the bike was sporting a decent set of Land Cruiser tyres with wheels that were known to be solid - I went for it. I stood up, put my weight on the pedals and rolled down the steps at a steady pace. I expected the usual bumps but ended up getting a whack. I dropped down as if my bike had collapsed and was on the tarmac before I knew it. My first thought was that a wheel had badly buckled, but upon inspection the cranks were both pointing straight down. I vowed on the spot that had to be my first and last cotter pin failure and walked the bike home!
When I tried to buy a cotter press, I couldn't find anything on sale in Europe. When searching online, I could only find the ones made by Bike Smith (as recommended by Sheldon Brown here). They look ideal but as it's a heavy item it costs a lot to ship it to the UK. Very occasionally vintage presses come up on eBay, but they are usually workshop tools that are expensive and heavy. Eventually, a couple of years ago, I found a seller on eBay USA who sold me one that looked remarkably similar to the Bike Smith design.
I highly recommend you buy or make a tool like this, it has worked almost every time, very few cotter pins have bent or mushroomed on me. Yes, there is still the odd one that is seized beyond removal. But most importantly, installing cotter pins is far more reliable. Even after the 50-100 mile check, the pins have rarely needed further tightening.