This is also why those computers said "It's now safe to disable the power" after shutting down.
On old AT systems (the ones where Windows 9x would show "It is now safe to turn off your computer"), one could actually press and hold the power button and the system would stay running. And when you're bored you can also quickly move your finger off the button and jab it down again (this would flip the switch back to on), and if you're quick enough, the system would not see that there was a power interruption.
Indeed the old AT power button was a mains (120V) switch, with thick cables going from and to the power supply unit.
It is BIOS+Hardware (the PSU is not involved). As a matter of fact to "switch on" a ATX power supply (not connected to a motheboard) you normally use a paperclip (or a short piece of cable) to connect the green with any of the black see:
https://forum.overclock3d.net/showthread.php?t=394
The whole point is that (unless the PSU has a mains switch and it is turned off) an ATX power supply is always partially ON, powering (parts of) the motherboard at all times (this allows for such things as Wake on Lan or switch on via CTRL+F11 or dedicated key on the keyboard).
Rather, closing the button circuit (ie, pressing and then releasing) will directly shut off power on the motherboard, the OS cannot prevent this.