Since the problem started after upgrading to macOS 27, it would be worth carrying out a few checks to determine whether it is a software issue or something related to your MacBook Air's startup settings or power management.
I suggest working through the following steps in order.
1. Check Apple's guidance on automatic startup
Apple has a useful article explaining why some Mac laptops turn on automatically when the lid is opened or power is connected, and how this behaviour can be changed.
Prevent a Mac laptop from turning on when opening its lid or connecting to power
As your MacBook no longer starts as expected, this is a good place to begin. I would avoid changing any Terminal settings until the cause is clearer.
2. Establish whether the Mac is sleeping or shutting down
When you open the lid, is the MacBook failing to wake from sleep, or has it actually shut down? This distinction matters because the two situations have different causes and troubleshooting steps. Make sure the battery is charged and disconnect any external accessories before testing again.
3. Try starting in Safe Mode
Since the problem appeared after the macOS upgrade, Safe Mode is a useful way to check whether software loaded during startup might be contributing to the issue.
- Apple silicon: Shut down the MacBook, then press and hold the power button until startup options appear. Select your startup disk, hold Shift, and choose Continue in Safe Mode.
Follow Apple's instructions here: Start up your Mac in safe mode.
Once logged in, restart normally and check whether the original problem persists. If the issue disappears in Safe Mode, a software conflict becomes more plausible, although this does not confirm the cause.
4. Check for macOS updates
Go to System Settings > General > Software Update and install any relevant updates available for your MacBook.
Apple's instructions: Update macOS on Mac.
5. If the problem continues
If the MacBook still requires you to hold the power button for around 10 seconds, consult Apple Support before making further changes. Depending on the model and findings, it may be appropriate to investigate startup preferences, power management, firmware or hardware.
You can also refer to Apple's guides on Mac startup problems and Apple Diagnostics.
To help narrow things down, could you confirm your MacBook Air model, and whether the problem occurs every time you open the lid or only after the Mac has been asleep for a while?
With those details, we should be able to focus on the most likely cause without making unnecessary changes to your system.