There seems to be an issue with some of the new Surface Pro 2017 models that have found their way to new owners. Several owners so far have reported the same annoying problem - their device is randomly hibernating or shutting down, causing some serious inconvenience. There's a whole thread on r/Surface devoted to the issue, and some people trying to fix things on the Microsoft forums as well.
If you're running into the problem, it seems like there's only one thing you can do to fix it - a factory reset. Here's a comment from Microsoft Community Forums user Becca05, talking about that fix.
Update Everyone!!!! I called Microsoft and they suggested that I do a complete factory rest. I was kind of disappointed that they didn't have another fix to fix the problem. I did a factor reset to see if that fixed the problem. I did this 2 days ago and haven't had the problem since. I didn't have to touch the hibernation part at all. My computer hibernates only when I'm not touching my computer. I even watched a movie to see if it went into hibernation while watching the movie and it didn't. So far so good!!!
No word from Microsoft yet on how to fix this problem permanently, but we'll keep an eye out. Hopefully, these are just a few freak accidents, and not a full-on widespread issue. As it stands now, we've gotten quite a few reports from people who have experienced this problem.