Given that your nail heads were covered, I would have just bent them back and broke them off. But if they came out and you have holes on the other side that's fine. Honestly every trim/nail-type might have a best method so there isn't anything that someone can categorically say.
To go into existing holes... Get a better quality trim nail and use a gun. Up the pressure on the gun. When nailing into existing hole you want to hit the hole at an angle - maybe 30 degrees - so that your head doesn't shoot straight through.
Consider that the old nail holes have saved you the step of drilling pilot holes. If you are installing hardwood trim with a hammer and nail set it is easy to split the piece -- especially on seasoned wood. Since there are already nail holes in the trim, the chances of splitting the wood is very low. Here are some other suggestions:
If the opening is too large in that the new nail head won't get a purchase on the wood, use the next penny size up.
If you think the wood may split, blunt the pointed end of the nail by tapping it with your hammer. This allows the nail, when driven, to crush the wood fibers rather than chiseling (and expanding) them which is what causes wood split.
If you can't get the nail to bite into the wall stud or nailer in the wall, re-angle the nail in the pilot hole so it is driven in a different direction.
Drive nails until just the head is above the wood surface and then use the nail set to sink it 1/16-1/8 inch below.
If the nail is driven on a location that prevents hammering without doing damage, use the other (wider) end of the nail set to drive the nail head to just above surface and then use the pointed end to sink it.
Sometimes it is easier to chuck the finish nail in a drill so that the chuck tightens on the nail shank below the head. Slowly easing the nail into the wood allows the nail to bore through the wood grain to prevent splits. Stop short of the chuck's jaws hitting the wood and finish with hammer and nail set.
Finally, when pulling nails through trim, first clip the nail head off and then pry it through from the back. It will leave a smaller opening.