There are two things at play here.
First, as Stephen suggested, the firmware of your motherboard handles the signal from the button. Based on how long your press the button, the firmware will decide what to do.
The firmware will then send an ACPI signal to the operating system. A single quick press of the power button will send a power button signal. Pressing the reset button will send the reset signal. And holding the button will cause the firmware to cut power to the system without sending any signal to the operating system, which doesn't give the OS time to shut down in an orderly manner. In other words, all the scripts and triggers that normally fire on shutdown will not fire, because the firmware never sent a signal to the OS. This explains why your scripts aren't working on a long power button press.
To control the behavior, you need to configure how your operating system handles the ACPI shutdown signal. So if you want your computer to suspend for example, you would configure the OS to suspend on press of the power button.
But in the case of the long hold power button press, you do not get the opportunity to control anything because the OS doesn't receive a signal from the firmware.
If you follow the messages log
sudo tail -f /var/log/messages
to see what logind logs when you press the power button. On my laptop (lenovo t14) and my desktop (asus motherboard), they both receive the signal after the power button is released.
Aug 16 11:47:43 tp-01 systemd-logind: Power key pressed.
This makes sense as the board's firmware is waiting to determine if the press was long or short. This also means that since a long press will immediately cut power to the system, the power will be cut before you release the button, and the signal will never be sent.