It shuts down on its own...
1) Are there any warnings or advisories when the shutdowns happen? A shutdown without an advisory can indicate overheating. Have you confirmed that the the fan is operating and that it and the heatsink it services is not clogged with ten years of dust and lint? They get dirty. This was the heatsink the fan cools in my 2012 when I did the SD upgrade in 2017 (ignore the yellow arrows):
That pad of lint was about 1/8th inch thick and blocking the heatsink at the exact point where it gets the best airflow.
2) What SSD brand and model did you install? Not all work well in Macs.
3) When you changed the drive, did you replace the drive CABLE as well. That is almost required in that model. The cable is super-thin and its insulation thinner. If the insulation wears agains the sharp metal edges on the chassis from the the vibration of normal use and transport, it can short out. The symptoms that causes are dizzyingly diverse. Cables are available, cheap, and easy to install.