Without touching system settings or the terminal
Open SeventyAwake and click Stay awake: your Mac stops going to sleep, with no limit, for a ready-made duration (30 min, 1, 2, 4 hours) or for the exact duration you type, down to the minute. Tick "Keep the display on too" if you want the screen to stay visible, for a download or a presentation. Click Back to sleep and macOS resumes its normal sleep: no system setting to change and then remember to restore.
Download the free SeventyAwake trial (7 days, macOS 13+).
macOS lets you delay or disable sleep in System Settings, under Lock Screen (and Energy Saver on desktop Macs). It works, but the setting is global: you change it, you forget it, and the Mac stays awake for days. Fine for a server machine, painful day to day.
The caffeinate command that ships with macOS prevents sleep while it runs (for example caffeinate -t 3600 for one hour). Effective, but you need a terminal, the right flags and a window left open. SeventyAwake holds exactly the same power assertions, with a button.
With the lid closed, macOS puts a laptop to sleep no matter what: no app cleanly bypasses that protection. To work lid closed you need official clamshell mode: an external display, power plugged in and an external keyboard or mouse.
Get SeventyAwake: one click to stay awake, for life.