iPhone 4S turning off and discharging randomly
Having a trained repair person put a working battery in the device would let you know if the failure is simply due to battery / voltage or another hardware fault. Hard to tell without testing and doing the work, though.

Voltage drops is what causes the unexpected power off so corrosion or a faulty device that over draws the current that can be supplied can cause this. Also, perfectly working electronics won’t work if the battery is failing / failed.

Apple service diagnostic can usually tell if the battery is healthy, but I don’t know if they offer that service on this old of equipment anymore.