An idiom (and phrasal verb) that is in widespread use in English. It means to get something exactly right or to produce the correct solution/answer/response to a need.
Lorraine needed to make a perfect souffle to win the cooking contest and even though it was her first attempt at one, she nailed it and was awarded first prize.
Denis needed a 9.4 to win the diving competition and he nailed it with a triple somersault rated 9.6 by the judges.
It has a positive meaning. The implication is that some skill or effort is required so you wouldn’t use it to describe successfully doing daily chores or routine tasks.