I was facing this issue on my Macbook Pro in macOS Monterey. While I'm connected to the external monitor and the power cord is unplugged then the connected external monitor goes to sleep mode. Even if the Macbook lid is open.
1. Update Power Management Settings
Run the following command to prevent the mac from sleeping in any conditions -
sudo pmset disablesleep 1
You can run the following command to enable the sleep mode again whenever you need -
sudo pmset disablesleep 0
2. Update Battery Settings
Go to System Preferences, then Battery and select Battery again on the sidebar. Make sure your battery settings should look like this -
3. Update Power Adapter Settings
Go to System Preferences, then Battery and select Power Adapter on the sidebar. Make Sure your power adapter settings should look like this -