Note: Windows 10 instructions can be found here
To prevent the computer and screen from sleeping automatically, use these steps:
Open Settings.
Click on System.
Click the Power & battery tab.
Under the “Power” section, click the “Screen and sleep” setting.
Choose the Never option to prevent the screen from turning off.
Choose the Never option to prevent the computer from going to sleep.
After completing the steps, the computer will stop automatically entering sleep mode, even if you are not actively working on the device.