it's actually an idiom, not a slang.
figuratively, it means:
1. to do something exactly at the right thing or to do something in the most effective and efficient way:
"you've done drafting the report at the specified given time? wow! you hit the nail on the head."
2. to describe the exact cause or problem of a situation:
"John hit the nail on the head when he said that what's the real problem in the society is discipline."
3. to be right about something:
"my friend hit the nail on the head when she said that she can study chinese in two years."
the common relevant expression I can think of is "hit the bull's-eye!" and "hit the mark!"
:)