I have the same dreams when I need to pee while asleep, but something prevents me from wetting the bed. I dont know what that is however. I often dream that I am searching for a toilet but they are all occupied, or broken and this prevents me from going.
At this stage my brain takes over and says, "wait a minute, this isn't real" and I tend to wake up. On occasions I actually dream that I am peeing, but I 'pee' for ages and the need to go does not decrease. Once again my more conscious brain intervenes.
I am a relatively light sleeper, but I presume if you end up wetting the bed you sleep more heavily and the signals are not getting through to wake you.
As others have suggested, visit the toilet immediately prior to going to bed every night, and perhaps lie on a couple of towels, to prevent your bed being ruined.