My bet is on either thermals or power supply.
Not likely to be RAM, since issues there are more likely to either prevent the machine starting in the first place, or lock up if it fails while the machine is in operation.
Not likely to be CMOS battery since that generally wouldn’t cause the machine to shut off, it just preserves firmware settings between power cycles.
In theory, there could be an intermitted short happening somewhere and the PSU’s OCP is kicking in, but I’ve never come across something like that. Similarly, there could be a problem with an internal power cable connection doing the same, but it sounds like you’ve already checked that.
I would test with a different PSU if you can. Thermals should be easy to check for too with the many pieces of available software to keep track of such things.
Not a zoomer, but I am on the youngest edge of millennial – the first computer I remember using was running Windows 95, and our first home computer was a Pentium era HP. My love for the older stuff didn’t start until I was much older.