"Nailed it" comes from the idea of hitting a nail on the head perfectly—doing something exactly right without any mistakes.