Hi,
It can be caused by either it's overheating or it's set to turn off if you're not using it. Here are some troubleshooting steps that may help.
- Start by checking all your Power Options.
- Open Power Options and click on Change plan settings then Change advanced power settings on the next screen.
- Expand Hard disk first then set Turn off hard disk after to Never.
- Expand Sleep and set Allow hyrbid sleep to OFF and set Hibernate after to NEVER.
- Click Apply and OK.
- Do open Device Manager next and set your keyboard and Mouse to wake up your PC.
- In Device Manager right click on Mouse/Keyboard and select Power Management.
- Make sure there's a check on Allow this device to wake the computer and click OK.
- Do test your PC again after doing all these changes.
- If the same problem does persist you'll need to open your laptop and clean the inside of it.
- Remove all the dust on the fans and apply new thermal paste on both the CPU and GPU.