Download the freeware OCCT and run the PSU test and see if it shuts down during that test or any of the other two tests - CPU and GPU.
During the testing keep a close eye on Temperatures, Fan speeds, and especially PSU Outputs 3.3/5.0/12.0 Vdc.
If any PSU outputs goes below 5% during the testing, especially the 12.0 vdc, that indicates a failing PSU.
According to a CPU & GPU - PSU requirement website it says this about your CPU and GPU and PSU:
What PSU fits AMD Ryzen 7 5800X and NVIDIA GeForce RTX 3070?
You need a power supply with at least 550W
NOTE: When a PC shuts down without powering off that indicates:
Overheating, Power, Overclocking issues, RAM issues (defective or incompatible), Driver issues, Defective hardware issues are some of the main reasons.