The Proto-Indo-European root is *h₂enǵh- "tight, painfully constricted, painful". This became Proto-Germanic *anǥ- "compressed, hard, painful". In Old English, this combined with næȝl "nail" (from PIE *h₃nogh- "nail, claw") to form angnail, which, influenced by the word hang, changed thru folk etymology to hangnail.
In Latin, the root became angō "to torment", then ānxius. This was borrowed into English as anxious probably in the 1600s.