Thank you for contacting Samsung KSA
make sure that your device is on the last update
avoid downloading unknown apps from unknown sources as it may be the reason for auto-restart
make sure to disable auto-restart from :
Settings - Device care - 3 dots on top of the screen - Advanced settings - disable Auto Restart.
if your device support Bixby Routine kindly check if there are any routines have been set
try to restart your device in the safe mode and check as safe mode is useful step to stop all third party apps
and if you still face the same issue you can visit the nearest service center in order to check
the link of the service centers :
Hope you and your family staying healthy and safe!