If you are dealing with loose nails, and not screws, take a new nail and drive it tight against the head of the old one. By the time you set the new one, the head will overlap the old, and keep it tight. You might need three light coats of mud applied, until you fill the dimple, since each coat will shrink a bit. If you have any doubts about the work, after you sand, check the wall with a lamp. Take any lamp, even a table lamp with the shade off, and hold I tight to the wall, a foot or two away from the repair. The light shining across the wall surface will make any flaws evident before you paint.
Depending on a lot of factors, "spot" touch-ups can be pretty unsuccessful, and you may have to repaint the whole wall to make it look decent again.