Back wheel skidding out
Check the tyre pressure anyway. You should be within the limits printed on the tyre. I would be a little surprised if low pressure caused sliding, normally it's high pressure on a rough surface that causes your wheel to skip across the top of the bumps and move sideways when it's airbourne between bumps. In that case lifting your bodyweight slightly with your legs can help soak up the bumps and increase traction.

But if you were unweighting the rear wheel by standing and pedalling hard that's not too unusual. Try to avoid it by pedalling more smoothly, ideally from the saddle.

edit: at that speed I think it's just basic bike handling skills. As you ride more that will be both less likely to happen and bother you less when it does. It might help to play on gravel a bit (possibly on a MTB or old bike). If you really want to push that along either mountain biking or bike polo are good ways to improve your bike handling.