This phenomenon occurs to me also from time to time, but nowadays it's very rare, thankfully. After a while I got used to it, so it's not that frightening anymore. Also I learned to avoid it in most situations. Sleep paralysis for me was always preceded by some kind of cold, icy sensation across my spine, so eventually I learned to wake up quickly before this "ice grip from hell" (often accompanied by the sensation of a demonic presence) could seize me. Sometimes I can't react fast enough, but since it has happened so many times, I'm not really afraid of it anymore, even though it's still of course very unpleasant. In my opinion, the best thing to do when this occurs is to completely avoid struggling since in my experience, the harder I try to sit up in bed, the more stuck I get.
As for what can trigger this experience, I'm uncertain, but generally when it has happened to me it has been when I'm deviating a lot from my normal sleeping patterns, and always when this has happened, I've been lying on my back.