I would check two things:
- Check that your power supply is powerful enough as Sineos mentioned, and in any case, try another good one just in case. Note that it must be able to provide high current at 5V, higher voltages cannot be used by RPi.
- Check that your RPi does not overheat. You should have heatsinks and a fan installed for cooling. Without this, RPi5 can get too hot on high workloads.