The laptop may have a failed motherboard component or a short somewhere, which is causing it to shut down prematurely for its own safety. It may also be thermally throttling itself, overheating due to a nonfunctional fan, dirt clogging up vents, or dry thermal paste. Is the laptop very old? You may want to have it serviced, as this sounds like a hardware problem.