I went through this with one of my kids many years ago. Personally, I think most of the time it's not necessarily medical.
My kid was afraid of the dark so he wouldn't get out of bed to pee during the night. We put in numerous night-lights and he quickly learned to get up and go!!!
I'm sure there are many other reasons children wet their beds, but simply taking the time to talk to your kids about it can work wonders.