The "fingernail" sense seems to be the original one. Nail polish attested from 1891. To bite one's nails as a sign of anxiety is attested from 1570s. Nail-biting is from 1805. Hard as nails is from 1828. To hit the nail on the head "say or do just the right thing" is first recorded 1520s. Phrase on the nail "on the spot, exactly" is from 1590s, of obscure origin; OED says it is not even certain it belongs to this sense of nail.