If your iOS or iPadOS device restarts or displays the Apple logo or a spinning gear unexpectedly, read this support article for how to resolve this --> --> If your iOS or iPadOS device restarts or displays the Apple logo or a spinning gear unexpectedly - Apple Support
It has you:
- Check your software
- Check your hardware
It is sounding like there may be water damage.
Go to this page to find your nearest Apple Authorized Service Provider (AASP) or Apple Authorized Distributor (AAD) --> Find Locations
How to make a Genius Bar appointment
1. Go to Genius Bar Reservation and Apple Support Options - Apple
2. Go to "Get hardware help".
3. Select your hardware and continue selecting options requiring replacing parts until you see "Bring in for Repair"
4. Sign in with your Apple ID