Anvils allow you to enchant anything, but the /enchant command doesn't
You can't /enchant something that can't normally be enchanted in survival mode, like putting Knockback on an axe, which is kind of silly to not allow being that it is a weapon, but you can use an anvil to put Knockback on anything, including literally a grass block, without even using cheats.
Steps to reproduce
- Get a netherite axe and hold it
- run /enchant @s knockback 2
the command fails
3. Get a Knockback II enchanted book
Try to combine the book with the axe.
Notice The anvil allows it (and that the enchantment functions as it would with any other tool).