I have the Samsung Galaxy S 8 and it randomly shuts down and reboots by itself. This seems to be a common problem with this phone. It appears that Samsung is ignoring the issue, as the problem goes back for a long time and people are still having this problem. I haven't found any response on any forums addressing this problem from Samsung. Some recommended fixes are to replace the mother board, replace the phone itself, factory reset and safe mode but apparently none of these have worked for everybody.
I sent my phone back to my provider and they sent me a free replacement. I believe the problem was because I initially had a Samsung S5 and used Smart Switch to transfer all of my apps from the S5 to the S8. That's when the auto shut down/reboot started. So, when I got my replacement S8 phone, I decided to not use Smart Switch and just downloaded all of my apps that I had on my S5 phone with a fresh start. I haven't had the problem again, as of yet! I think the problem is with the compatibility between the S5 and the S8 operating system.