Men are familiar with the concept of morning wood. You wake up from a restful night's sleep, stretch your arms, and find your dick standing proudly to greet you. You're not aroused or anything, but here you are with a full erection anyway. What you might not realize is that morning wood is actually your cock's last salute of the night after a busy twilight of boners.
Morning wood is the final erection in a cycle called nocturnal penile tumescence (NPT), which generally occurs in concert with REM sleep. This is when your body and mind are most active during sleep, and when dreams happen. NPT doesn't happen in concert with any arousal or stimulation; you're just sleeping and popping boners. Most healthy men up to middle age can expect to experience REM sleep and NPT 3-5 times per night — and never even realize it. NPT erections can be long-lasting, often up to 30 minutes or more. If you've ever woken up in the middle of a night with a boner that just wouldn't go away, that's NPT.
The thing with morning wood is that it only happens when you wake during REM sleep, which is not the natural point in your sleep cycle to wake up. So if you're waking up to an alarm interrupting your dreams, you're more likely to experience morning wood than if you wake naturally without interruption. So if you're not experiencing morning wood, it's more likely a sign that you're waking at the right point in the sleep cycle than dealing with erectile dysfunction.
NPT's predictability is actually used as a diagnostic test for narrowing the cause of erectile dysfunction. A doctor will fit a man with a device that's attached to the base and tip of his penis and will register any erections that occur during the night. If the man still experiences NPT, then it's likely that psychosomatic concerns are the cause of his erectile dysfunction, while not having sleeping erections points to physiological issues.
While scientists can easily explain how nocturnal penile tumescence works, they have a harder time explaining why. It occurs predictably alongside REM sleep but without any external stimulation or mental arousal (I've more than once awakened from a nightmare with a raging boner). It's possible that hormonal fluctuations associated with NPT drive these erections, but doctors aren't yet certain. There is no known function in penile growth, size, or health associated with NPT.
One thing that is accepted is that NPT and morning wood likely have nothing to do with preventing urination from a full bladder, as women experience a similar nightly phenomenon in nocturnal clitoral tumescence and the clitoris has nothing to do with urination. Also the fact that NPT boners come and go while your bladder continues to fill through the night.
NPT and morning wood decline in strength and frequency with age, usually starting around 40-50 years old. A study found that most men over 60 didn't experience full erections in their sleep, though that was not necessarily indicative of their ability to achieve an erection for sexual purposes and most still reported having regular sex with their partners. It's possible that a natural decline in testosterone levels as men age may be behind to the decline in NPT.
A number of other factors can cut into the occurrence of NPT and morning wood, including low levels of hormones like testosterone, cardiovascular issues (as the penis is a vascular organ), dehydration, poor sleep quality, and certain medications like muscle relaxers and heart pressure meds.
The thing with NPTs and morning wood is that science has found no definite cause for the nor certain reason why our bodies do it. It's just a fact of life for men with penises of all sizes. Not experiencing morning wood isn't necessarily a cause for alarm — it might just mean you're sleeping well! As long as your dick still gets hard when you need it to be, there's nothing to worry about there.