Hello, We understand how frustrating it can be for your phone to restart in the middle of using it. The steps provided by ButtaBean420 is a great place to start to make sure the Auto Restart feature is turned off.
We also recommend testing the phone in Safe Mode to make sure there are no apps causing the behavior. If the phone restarts in Safe Mode, then a factory reset is recommended. You can find the steps here: https://www.samsung.com/us/support/troubleshooting/TSG01001475/
If the phone is auto-restarting after completing all the troubleshooting, it is recommended to have the phone evaluated at an authorized service center. You can use the following link to find a list of service centers in the U.S. that can do the repair: http://www.samsung.com/us/support/service/location or by contacting customer support at 1-800-726-7864.
For assistance outside the U.S., please use this link: https://www.samsung.com/us/common/visitlocationsite.html