Bedwetting can have a relationship to how we are breathing and the quality of our sleep. Since breathing can be difficult with sleep-related breathing disorders, the brain works harder to take in oxygen than it does to control other bodily functions, like bladder control.
The brain is sensitive to reductions in oxygen levels, which may trigger flight-or-flight response and refocus oxygen from something less necessary (like the bladder) and deliver it somewhere more critical preparing for the rare case the oxygen were to stop.