Reference:
-NoRestart
Suppresses reboot. If a reboot is not required, this command does nothing. This option will keep the application from prompting for a restart or keep it from restarting automatically.
-All
Enables all parent features of the specified feature. If a parent feature is required for the specified feature to be enabled in the image, All will enable the parent and all of its default dependencies.
To supress the reboot prompt add the -norestart switch.
As to why the GUI gets installed... I do not have a VM with the same OS as your server, so I can't test for you.
Based on your replies you apparently have a parent feature; Windows-Defender-Features, and a sub feature; Windows-Defender.
If you installed Windows-Defender, and it didn't work, then that would indicate to me that it's parent feature might also be required. But since you don't want the GUI, then you don't want to use the -All switch because the GUI might be tagged as a default.
If you are testing on the same machine, make sure that all defender features are uninstalled and you reboot before trying again.
Try this:
Enable-WindowsOptionalFeature -Online -FeatureName "Windows-Defender-Features" -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName "Windows-Defender" -NoRestart
add shutdown to reboot if desired/required
Update: What is the issue with installing the GUI feature? If I have a server that I suspect is compromised, then I would RDP to it, verify that the definitions are up to date, and then initiate a full system scan, most likely using the GUI interface. I don't know what specific functionality that feature enables, but it seems to me that at worst, it shouldn't hurt anything, and at best, I would need it to manage Defender.