I have a few cotter pin crank bikes.
If you simply hammer out the cotter pin you’re not doing your bearings or your frame any good.
There are special tools for the job, but for home mechanics, it is necessary to improvise.
Use a tube to transmit the impact through the crank to the floor. I use a cut down straight handlebar.
Leave the nut at the top of the thread which helps protect the thread from the hammer.
Rest a heavy hammer (lump hammer or spalding hammer) on the nut and strike this firmly with another hammer. As straight a blow as is possible and you might avoid bending the threaded part of the pin. It also helps to prevent damage to the crank by a near miss because the lump hammer is a bigger target.
One good whack is usually all that is needed.
Do it the other way and you can be hammering away for ages and end up turning the threaded part of the cotter pin into a rivet head.
When replacing a cotter pin, the threaded part should project upwards when the pedal is forwards.