Sometimes hitting a nail means a fingernail. Well here are some steps to help you avoid hitting the wrong nail.
First grip the hammer with your hand. Place your hand toward the bottom half of the hammer. Then extend your thumb up along the handle. This helps guide the hammer when you swing it towards the nail. A little thing that I do is extend my little finger out only gripping the hammer with 3 fingers. To me this helps control my swing on the hammer.
Next I grab the nail and place it where it needs to be hammered in. Gripping the nail with my thumb and index finger of my non swinging hand. Then I take SMALL swings to help tap it in place, making sure the nail is not at an angle, and secure in the object.
Then the most important step is to remove my non swinging hand about a foot away from the nail. Then I start taking harder swings hitting the head of the hammer square on the nail head. Looking at the nail all the time while swinging, not my other nail.
An important thing to remember is to not swing the hammer back towards your head, but at an angle that is equal to your swinging arm shoulder.