MacBook shuts down at login screen
Did you check by doing PRAM and SMC Reset.It may be hardware issue.Please follow the below steps.
Reset the SMC on computers that have the T2 chip
If your Mac has the Apple T2 Security Chip, follow these steps. If you need help, contact Apple Support.
Notebook computers with the T2 chip
Before resetting the SMC, try these steps:
Shut down your Mac.
Press and hold the power button for 10 seconds, then release the button.
Wait a few seconds, then press the power button to turn on your Mac.
If the issue persists, follow these steps to reset the SMC:
Shut down your Mac.
On your built-in keyboard, press and hold all of the following keys. Your Mac might turn on.
Control  on the left side of your keyboard
Option (Alt)  on the left side of your keyboard
Shift  on the right side of your keyboard
Keep holding all three keys for 7 seconds, then press and hold the power button as well. If your Mac is on, it will turn off as you hold the keys.
do the following to reset PRAM on Mac:
1.Turn off your Mac.
2.Press the power button.
Immediately press the Command+Option+P+R keys.
Hold the keys until your Mac restarts and you hear the startup sound 3 times .
Release the keys.
Reference : https://support.apple.com/en-in/HT204063