I had an old pc behaving like this. It would just shut down whenever, randomly: 5 seconds after the first beep when the pc turns on, while windows was loading, after the login, while playing, while doing nothing, literally it could happen whenever. Tried everything i could, software wise but without any avail. I had some spare parts so I changed ram, psu, removed gpu, put new hard disk: nothing worked. Moral of the story? It was the motherboard. Changed only the motherboard and the pc works just fine… 🤷🏼♂️ so it could also be a problem with the motherboard. If you can, be more specific in saying when those shuts down happen or if you can reproduce them, it could help you a lot