system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How does our body know/learn not to wet the bed when we're sleeping?
gpt
As an infant our bladders just fill and release.  As we grow and our bladder increases in size and the muscles controlling it get stronger we learn to control that impulse.

At night, two things happen.  One is we release a hormone called  vasopressin that suppresses the formation of urine during sleep.  Instead that liquid gets reabsorbed into the bloodstream and less goes into the bladder.  

And secondly as our bladder fills, it sends a signal to the brain. The brain sends a signal back to the bladder telling it to relax so it can fill with more urine.  As it fills that message to the brain *should* eventually result in us waking up so we can eliminate appropriately.  

With kids with bed wetting issues, they often have issues with either not producing enough of the hormone, not getting that signal to wake up, or other issues.