Open the lid of a shut down MacBook and it turns itself on. That is annoying when all you wanted was to wipe the keyboard.
Apple documents a firmware setting for this. In Terminal:
sudo nvram BootPreference=%00 # not on lid open, not on power
sudo nvram BootPreference=%01 # only block lid open
sudo nvram BootPreference=%02 # only block connecting power
Pick one line, type your password (nothing appears while you type) and shut down to try it. Pressing a key, the trackpad or the power button still turns the Mac on.
I would pick %01 if the lid is the only annoyance, so that plugging in the charger behaves as before.
To get the normal behaviour back, delete the variable:
sudo nvram -d BootPreference
It needs an Apple silicon laptop with macOS Sequoia 15 or later. Type the line exactly as shown: nvram writes to firmware settings, so this is a place to copy carefully and not to experiment with names of your own. And it only concerns a Mac that is shut down. Closing and opening the lid of a sleeping one still wakes it, as it always did.
Further reading: Prevent a Mac laptop from turning on when opening its lid or connecting to power