Hi, Samson Soboka
This behavior is more consistent with a charger, battery, overheating, or internal power-circuit problem than a normal Windows shutdown setting. A sudden power-off without an error message especially points toward hardware protection being triggered.
Besides the solutions provided by the Q&A Assist, here are some suggestions you can try:
Shut down the laptop and disconnect the charger. Inspect the charger cable, connector, and laptop charging port for bent pins, looseness, burn marks, or unusual heat. Do not continue using the charger if you notice damage. HP notes that an adapter can stop output because of overcurrent, overheating, or a short circuit. HP AC adapter troubleshooting
Note: This information is provided as a convenience to you. The site is not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
Turn on the laptop and repeatedly press Esc at the HP logo, then press F2. Under Component Tests, run the Battery and AC Adapter tests. Record any failure ID displayed.
Reset the laptop’s power controller. Turn it off, unplug the charger and accessories, hold the power button for about 15 seconds, reconnect only the charger, and start it again.
Test with another genuine HP charger of the exact required wattage, if available. If the diagnostics fail, or the laptop still shuts down with a known-good charger, contact HP because the battery, charging port, or motherboard power circuit likely needs inspection.
Thank you for your patience in reading, I hope this information has been helpful to you.
If the answer is helpful, please click "Yes" and kindly upvote it. If you have extra questions about this answer, please click "Comment."
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.