That's not lucid dreaming, that's sleep paralysis.  They're not exactly sure how it happens, but they theorize that it might be caused by an imbalance of sleep hormones that keep you from moving around too much at night. It's like the opposite of sleep walking.