MacBook Pro shuts down while in "Login Window"
I would probably start with testing to see if this behaviour is replicated when booted into Safe Mode and if the issue persists then running Apple Diagnostics.

Boot into Safe Mode 

Follow these steps to boot your Mac into Safe Mode: 


Fully shut down your MBP 
Restart your MBP 
Immediately press the Shift key and keep it down 
Let go of the Shift key when you see the login window (NOTE: If you have FileVault enabled you may need to log in twice). 
Take a note of what happens (i.e. does your MBP still end up going to sleep, etc) 
Exit Safe Mode by restarting your MBP as normal 
Test again when booted normally 


If the problem doesn't occur while booted into Safe Mode, let me know and we'll go from there. 

If the problem persists, proceed with running Apple Diagnostics.

Run Apple Diagnostics

Follow the steps below to run Apple Diagnostics:


Fully shut down your MBP
Restart your MBP
Immediately press the D key and keep it down until you see the Diagnostics screen appear
Wait for Diagnostics to finish (this typically only takes a few minutes)
Once complete, one of two things will appear on the screen:


a No issues found message
a brief description of any errors found plus further instructions

If the diagnostics test does find errors, take a note of what they are


Note: If pressing and holding the D key at Step 3 doesn't work, start again at Step 1 and, at Step 3 press and hold both the OptionD keys instead. This will try and run diagnostics from the internet instead, so you will need to allow more time for it to complete. 

Regardless, take a note of what happens and let me know how you went.

[UPDATE]

Since we've established the problem is not occurring when booted into Safe Mode then it's time to investigate login items, fonts, and kernel extensions. 

Investigating login items, fonts, and kernel extensions

Let's start with Login Items:


Startup normally
Go to System Preferences > Users &amp; Groups
Select the Login Items tab
Take a note of your Login Items 
Now remove all of them by highlighting them and clicking on the - button below
Restart your computer


Now your Mac will boot up without those login items loading. Test to see if you can use your Mac without it going to sleep, etc:


If you can, you know one (or more) of the Login items were causing the problem. You can then add them back in one by one until you've identified the culprit. Problem solved.
If the problem does persist, it's either a problem with fonts you've installed yourself or with a 3rd party kernel extension. A little more info below:


Fonts:- You can remove any of the fonts you've installed yourself to see if this makes a difference. For more info, read the following Apple resources:


How to install and remove fonts on your Mac
Mac OS X: Font locations and their purposes


Kernel Extensions:- You can open Terminal (found within your Utilites folder) and enter the following command:

kextstat | grep -v com.apple

The above command will list 3rd party kernel extensions (you may need to stretch the Terminal window so it's easier to read). Look for anything you don't remember installing, or something that belongs to software you've removed, or just anything that looks out of place. Remember though, this is a list of 3rd party kernel extensions and therefore any of them could be causing the problem.