One function is 'PIV' - acting as a 'smart card'. When you create or load a key, you can choose whether you want to require a button press or not [1]. They strongly recommend requiring a button press.
No physical button press = an attacker with root can sign things at will.
[1] https://docs.yubico.com/yesdk/users-manual/application-piv/p...
If you choose to not require touch for your Yubikey it's user error
Yubikeys work great if used as designed.
I believe one option on each certificate in the PIV applet is whether or not a "button press" is required for its use. I believe it is recommended that the device attestation certificate at least is not guarded by the button press.
The threat model for yubikeys is to prevent the key being cloned - if it's in your pocket, it's safe. If you plug it in, and authenticate by PIN to the PIV applet, and push the button when prompted, someone may be able to generate a signature.