we are sorry to hear about this experience from this device do not worry you can place the request for replacement for this might be possible your device is refurbished.
Dear Samsung Member,
Greetings from Samsung Customer Support!
We are sorry for your inconvenience. To resolve auto restart issue please follow below given steps:
Go to Settings > General management > Reset > Turn off auto start.
For further assistance, register your concern in Samsung Members Application (Open Samsung Members Application > click on “+“icon > send feedback > error report/ask questions).
Thank you for writing to Samsung.
Samsung Customer Support