I reviewed your post and I understand that the computer is not booting to Windows and shuts down randomly.
Don’t worry, I assure you I will try my best to get this sorted.
I recommend you boot to BIOS and check whether the computer is shutting down even in the BIOS screen. If yes, then it is a hardware issue and I recommend you contact support and check the available service options for your computer.
Be alert for scammers posting fake support phone numbers and/or email addresses on the community. If you think you have received a fake HP Support message, please report it to us by clicking on "Flag Post".