In my experience, the problem with tapping is that it just mushrooms the head - (at least with the soft cotters available today).
Conversely, I've set many cotters with a strong, deliberate blow, and can attest that they stayed put. Again, this method requires that the crank arm be
completely supported from underneath to prevent damage to the bearing surfaces, and whacking is NOT the best method in any case: The
cotter press is.
JohnDThompson makes a very critical point - A smooth flat surface on the cotter is essential. (On a lot of the new cotters this surface isn't even flat to begin with.

)
PS - After you set a cotter (by whatever method) it is also important to set it again after the bike is ridden, and then tighten (but not over-tighten) the nut.