This is a really good study that was done showing the many links between the bladder and brain, and it goes into detail for how things work versus how they can commonly go wrong. It's a little long, and technical, but worth reading for many here.
https://arstechnica.com/science/2024/06/to-pee-or-not-to-pee-that-is-a-question-for-the-bladder-and-the-brain/