Hello hayleynix0726,
For help with you iPhone unexpectedly restarting, were you holding the side button long enough to see the Apple Logo? If not, test the steps below found in the article here: If your iPhone won't turn on or is frozen - Apple Support
"On your iPhone 8 or later, including iPhone SE (2nd and 3rd generation)
- Press and quickly release the volume up button.
- Press and quickly release the volume down button.
- Press and hold the side button until you see the Apple logo.

- If your phone doesn't turn on, follow these steps to check your hardware and charge your phone. You might need to charge for up to an hour.
- If your phone still doesn't turn on, contact Apple Support."
If the issue continues, test the steps while connected to a computer with iTunes or Mac. Follow the steps here: If you can't update or restore your iPhone or iPod touch
Should the issue remain, reach out to Apple Support directly to help check on your options and further assist.
Contact - Official Apple Support
Contact Apple for support and service - Apple Support
Best.