ok so it seems your mobo has both system fan and cpu fan headers
I'm guessing cpu fan is using a 4 pin ATX connector, otherwise you wouldn't have been able to plug it straight into the power supply
looks like the system fan uses a molex connector and that goes on the motherboard, you should be able to see SYS_FAN written somewhere on your mobo.
so possible causes for your pc shutting down
1. because system fan is not running to exhaust hot air AND cpu cooler is inefficient (either the fan is dusty / clogged up or the thermal paste on the bottom of your cooler that makes contact with the cpu has dried and flaked out), these coupled together result in the cpu getting too hot and having to turn off to avoid cooking itself to death. these older AMD cpus are notorious for the heat they put out.
2. power supply's fan is completely clogged up and can't spin, that will exhibit the same behavior and shut itself off
3. power supply is damaged and on its last legs, one of the internal components might have popped out. if this is the case , you'l have to get a new one, don't try to get inside and diy. ATX PSUs start from from 20$ or so, you don't need anything fancy, nor do you need the exact same one you had before.
I'd first try to find a way to power the system fan, either a molex header on the board, if that doesn't exist (look in proximity to where the audio jacks and usb that go out of the board are), a molex to 4pin ATX adapter cable
molex is on the left, the 4 pin ATX on the right goes into the power supply
2nd step and I would do this regardless, take off the cpu cooler (4 normal screws) , clean the fan blades with a can of compressed air or a brush, clean off the thermal paste residue on the bottom metal part of the cooler and replace with a pea sized drop of good paste
https://www.amazon.com/ARCTIC-MX-4-2...s%2C268&sr=8-4
you can use other ones, but preferably not the cheapest, silicon based pastes. put back on, tighten screws so that it makes contact properly, don't over tighten to infinity cause it can damage the board
take your compressed air can to the back of your power supply, where you can see a fan and give it a few blows, tilt it towards you to let the dust/hair fall out. I recommend you do this outside, if you've never cleaned your pc before, 8 years of dust and gunk will make a mess.
once you've managed to get the system fan working and the cpu cooler back in mint condition, test for temperatures with this
https://www.cpuid.com/softwares/hwmonitor.html .free, get the zip version so you don't have to install anything.
use your computer normally for a couple of hours with that software on the background, tell us what temps you got.