Losing total control of one's bowels can indicate a problem with something other than your bowels. You might have some sort of sleep disorder that's keeping you in too deep a sleep to respond to your body's signals that it needs to go. Your anus (I think that's the spincter muscle) may also be too relaxed to help you contain your bowels well enough. That's something to suspect if you have messed yourself while awake too. Physical therapy may can help tighten that muscle. I have also read that they are experimenting with using botox in the muscle in the bladder that can get too weak and cause people to leak pee. The botox stiffens and partially paralyszes the muscle so that it can stay in place better. Might work on the anus if it is too weak.
If you've never messed yourself before, though, then it might be a weird, random incident. Even normal people can get the stomach bug so bad that they mess themselves.