The reason you are not supposed to sleep flat on your back is that the weight of the fetus can compress a major vein and cause an unsafe drop in your blood pressure. If you are on it for an extended period of time could interfere with the flow of blood and nutrients to the placenta and your developing baby. Obviously, if you're doing it in your sleep there's not a whole lot you can do to stop it. It happens all the time and shouldn't have any serious adverse effects on your baby's health.
Maybe you can try to train yourself to sleep on your side or propped up with a few pillows. If you need to, place a pillow between your legs, under your hip, or behind your back to make your sleep position more comfortable. I used a body pillow and found it to be the most comfortable way to sleep - I still use it even though I'm not pregnant, when my back is bothering me.
at 7:53 AM on Jan. 28, 2011