Today I was riding a XC mountain bike down a semi-steep mountain with some big bumps and tight turns. I had me seat all the way down, was standing with knees bent, and correct stance like it should be. It worked for a little bit until I came to a turn and I felt I was leaning way too far back so I pulled myself forward to fix my stance but for some reason I went flying somewhat sideways off the bike. I was also braking a little throughout the ride but I'm pretty sure I use them correctly. What was I doing wrong? How can I prevent this. This has happened before and it's really hard to recover from while riding.