In this case, the victims may think they are using a generic USB cable, but the PC will recognize the cable as a Human Interface Device, much like it would a mouse or keyboard, giving the attacker just enough permissions to wreak havoc inside the system. This is different from all the other variations as this threat is much trickier to address with awareness practices.
Depends on your OS.
If you're on Windows you can use Penteract Disguised-Keyboard Detector which will lock the screen when it detects any HID.
If you're on Linux, I think there exists software that whitelists or blacklists USB devices, therefore avoiding the need for awareness.