Why? Why not allow or require it in both cases?
The default behavior when you close the lid on your MacBook is to put it to sleep. According to Apple:
You can save energy by putting your Mac to sleep when you're not using it. When your Mac is sleeping, it's on but consumes less power. And waking your Mac from sleep is quicker than starting it up after it's been shut down. To put your Mac to sleep immediately, do one of the following:
- Choose Apple () menu > Sleep.
- If you use a Mac notebook computer, close its built-in display.
- Press Command (⌘)–Media Eject(⏏).
- Tap the power button on your computer.
(Emphasis mine)
Having the AC adapter connected is just one of the components needed to override the default behavior; you need to have the AC power, keyboard and mouse connected, as well as a monitor. See Use your Mac notebook computer in closed-display mode with an external display for more details.