Hey there mirelav19,
Go through the following steps if your iPhone is shutting off unexpectedly. They could explain what’s goin on:
“Check your software
Make sure that your device has the latest version of iOS or iPadOS and that your apps are up to date. If the issue continues after updating your software and apps, check your hardware.
Check your hardware
On an iPhone 6 or later, check your battery health under Settings > Battery > Battery Health.
If your battery doesn't need service, and your iPhone, iPad, or iPod touch continues to frequently restart or turn off, contact Apple Support.”
If your iOS or iPadOS device restarts or displays the Apple logo or a spinning gear unexpectedly - Apple Support
Take care.