Mac mini turns off automatically by itself
It sounds like you might have an issue with the OS or an application that's crashing the OS.


A shutdown cause of 5 is a normal shutdown and nothing to worry about.  It's saying that it "shutdown correctly."
Shutdown of -62 is generally due to an unresponsive application.  


You should start with booting into Safe Mode to see if it's something being loaded.

Other options would be to wipe the drive with a clean OS (also a good time to upgrade the drive if you're still using an old spinning one). 

Personally, I would start with booting from an external drive, a clean copy of macOS to see if the problem goes away before embarking on swapping out hardware.