You may be downloading some big file for whole night or for any thing you want to stop your laptop/PC for going to sleep then below is the simple step to change the settings. We have took the screenshots from latest windows 11 and for your windows it may be different.
Go to the battery icon and press the right click
Click on the screen and sleep option
Set sleep timing according to your requirement on battery as well as when charging (plugged in).
If you want to make sure your laptop never sleeps then click on time section and you can change from 10 minutes , 3 hours etc, to never