The issue might be due to two reasons, one is due to the software issue and the other could be a hardware issue.
Update to the latest version
The first thing we need to do is to update to the latest version, this action resolves the glitches in the previous versions.
Force your iPad to restart
Forcing the iPad to restart rectifies the internal issues in the software and gives a fresh start to the iPad. Use the Sleep/Wake button and the volume buttons for the second-gen and the home button for the first-gen.
Check the battery
Shutting down frequently indicates that there could be a problem with the battery. Check the battery health and if it is below 80, go for the replacement.
Delete the rogue apps
The issue might be due to rogue apps, they bring in external malware into the device, so delete them and update all the apps on the phone.
Reset to default settings
The changes done by the users in the phone settings could cause this, so reset all the settings to default. Go to the reset settings and click on reset all settings.
Factory Reset
Factory reset could be an option if you have backed up all your data. This will delete all the data, install apps and sets the phone to default.
Contact Apple customer Support
If it is a hardware one try contacting Apple customer support, make sure you look up online about the issue before visiting them.