We use this expression to say that we have done the right thing, normally in the most effective and efficient way. We also use it when we want to describe a situation or problem exactly.
- You hit the nail on the head when you said lack of money was the source of the problem.
- She realised the mistake. She hit the nail right on the head!
In Spanish we also use a very similar expression: “Dar en el clavo”