As above. Hammer or press them into place and then the nut keeps them them in place.
It can be worthwhile filing the angle a little shallower too, so they fit deeper into the crank and make better purchase on the spindle although it is essential to make sure both are the same or else the cranks will end up out of alignment. Some cotterpins have a very oblique angled taper.
In the absence of a press, my preferred method is to just tighten the nuts, then a few sharp cracks from the other end with a hammer and you will find the nut is now loose - tighten it again and hammer it again and repeat until the nut stops coming loose and give the nut a final tightening without going mad and stripping it. Ride about 50 miles and check it again. You don't need a huge big hammer either, a typical 16oz claw hammer is enough and easier to hit accurately with.
Ideally, you support the underside of the crank when hammering cotterpins to prevent damaging the bottom bracket cups.
Incidentally, the secret in removal is to hit them hard whacks and the shock will free them (usually) because if you just tip tap at them you will probably rivet it into place and that is where the fun starts.