To "hit the nail on the head" is to be exactly right. It is a term used to announce that someone's comment or question is precisely the correct one. It is often used when someone unexpectedly asks the right question or gives the right answer. It can be taken two ways: One, as being lucky--as if someone has been swinging a hammer and missing the nail and has finally landed on the nail; and two, as being precisely calculated, as if someone has carefully aimed for the nail head and struck it.