If the backlight works correctly in this environment, a login item or driver is likely the culprit. Low battery mode or energy saver settings limiting power to the screen.
Fix Ambient Light Sensor to Restore MacBook Pro Backlight
Reset the System Management Controller (SMC) The SMC manages power management, including backlight behavior. If the sensor is obstructed or the calibration is off, the backlight may turn off or dim significantly without warning.
Boot in Safe Mode Safe Mode disables third-party extensions and background processes. Resetting it can fix irregularities.
Fix Ambient Light Sensor Calibration on MacBook Pro
Cleaning this area usually resolves unintended dimming. Logic board issues affecting power distribution to the screen.
More About Backlight not working on macbook pro
Looking at Backlight not working on macbook pro from another angle can help expand the discussion and give readers a second clear paragraph under the same section.
More perspective on Backlight not working on macbook pro can make the topic easier to follow by connecting earlier points with a few simple takeaways.