The two most likely reasons your MacBook screen has gone dark also happen to be very easy to remedy. For starters, try pressing a key on the keyboard or clicking the trackpad or mouse button. If the screen lights up and returns to normal, it was in power-saving Sleep mode.
You can adjust Sleep settings by clicking the Apple icon in the top-left corner and selecting System Settings (or System Preferences in macOS 12 Monterey and older), then clicking Lock Screen (Energy Saver in macOS 12 and older). From there, adjust the “Turn display off” settings to increase or decrease the amount of inactivity time before it shuts off — or turn the function off entirely so it will stay on.
Alternatively, a black screen could mean your MacBook is out of power. If that’s the case, unplug any external devices connected to your MacBook, then plug in the MacBook’s power adapter. Once the MacBook is plugged in, it should turn back on when you press the Power button. If it doesn’t, hold both the Command and Control keys on the keyboard and then press the Power button to restart. Not all unexpected black screens are related to energy consumption, however.