1) Check your settings and see if you have a quick timeout to auto-lock. The shortest time is 2mins up to never.
2) If the above doesn't help you try a hardware reset. Simultaneously press and hold down the home and power buttons until the screen goes blank and the Apple logo appears. Release the buttons when the Apple logo appears. You've reset the device and you don't lose any data.
The case is causing it to shut off. If you fold the case I bought (non Apple) all the way open so the front is folded flat against the back when the magnets line up it shuts the iPad off. As you use it in your hand and the case moves around a little it eventually lines up and off goes the iPad!