From a Psychology Today online article:
For those with insomnia, however, the stressor appears to be the lack of sleep, and the desire for sleep becomes a stressor in itself. In other words, the fixation on getting sleep leads to feelings of stress over not falling asleep, which begins a vicious loop. According to a model first proposed by Kales et al. in 1976, patients
can develop a conditioned fear of not being able to sleep, which puts them in a state of hyperarousal when they attempt to fall asleep. This makes their inability to sleep a self-fulfilling prophecy.
Insomnia is the most common sleep condition in the world, with half of adults globally reporting occasional episodes. Chronic insomnia, though far less prevalent, affects as many as 10 to 15 percent of the adult population.
Though these sleep problems are extremely common, the neurobiological mechanisms behind insomnia are not entirely understood. Research suggests that emotional stressors do play an outsized role in contributing to sleep problems, and it is well documented that mood and anxiety disorders are common comorbidities with insomnia. This seems like common sense. Emotional arousal, whether due to a state of anxiety or because of intrusive thoughts, makes it difficult to relax, thereby inhibiting one’s ability to either initiate sleep or get back to sleep after waking.