Did you check to see if your laptop qualifies for the free Apple repair program for an SSD as listed here?
Run the Apple Diagnostic to see if any issues are reported.
If you have any devices connected to the laptop, then unplug them. How about moving your laptop to another part of the house so it is using another electrical circuit in case you have a power issue in the house causing the laptop to shutdown. Even unplugging the power adapter from the electrical outlet for a minute & plugging it back in can reset the power brick. Just make sure to plug the power adapter directly into a wall outlet in case a surge strip is bad. Try an SMC reset & PRAM reset (hold the PRAM reset for a full minute so it is activated several times). Try connecting the laptop directly to your router using an USB-C to Ethernet Adapter and an Ethernet Cable so you eliminate possible WiFi connection issues. Then try reinstalling macOS again. You may even want to power cycle your modem and router. Make sure your laptop is powered off when you reset the modem & router.
Without actually seeing what is happening it is very hard to tell what the problem might be (it would be difficult even if we could be there watching it). It could be the installer is having trouble downloading the software from Apple for a variety of reasons, or perhaps your laptop has a hardware issue making it shutdown on you. If none of the above helps, then I think you will need to take the laptop to an Apple Store or Apple Authorized Service Provider to be checked out since I think you have a hardware issue with the laptop since the problems started even before the attempts at reinstalling macOS.
Please update this thread if you are able to sort it out.