It is the screen turning “Off”, that has macOS putting the Mac to sleep. Not to be confused with the screen saver, which puts up pretty pictures or animations while the screen is still powered on.
Amphetamine is a popular 3rd party app that prevents the Mac from going to sleep. Search Slack for the following string:
in:#ww-apple-users-int amphetamine
Make sure you have disabled "Log out automatically after inactivity".
System Settings -> Privacy & Security -> Advanced (at the very bottom) -> Log out automatically after inactivity -> disable [_]
Or you can keep the Mac awake longer by changing System Settings -> Lock Screen settings:
Using the Battery:
System Settings -> Lock Screen -> Turn display off on battery when inactive -> 1 min, 2 min, 3 min, 5 min, 10 min, 20 min, 30 min, 1 hr, 1.5 hr, 2 hr, 2.5 hr, 3 hr, never
Using the power adapter:
System Settings -> Lock Screen -> Turn display off on power adapter when inactive -> 1 min, 2 min, 3 min, 5 min, 10 min, 20 min, 30 min, 1 hr, 1.5 hr, 2 hr, 2.5 hr, 3 hr, never
If you are plugged into Power, there is a setting to stay awake when the screen turns off. Does not work when using the battery:
System Settings -> Battery -> Options -> [X] Prevent automatic sleeping on power adapter when the display is off.
You can set a Hot Corner, such that when you place your cursor in that corner it disables the screen saver. However, this requires you to remember to put your cursor in the hot corner whenever you leave your desk.
System Settings -> Desktop & Dock -> scroll to the bottom -> Hot Corners... -> Pick a corner -> "Disable Screen Saver".
If you wish, you can look at the sleep event log using the following Applications -> Utilities -> Terminal command:
pmset -g log | grep -e ' Sleep ' -e ' Wake '