^^ What EB said, macros don’t do “super smart” decision making for you. They can help identify friend from foe and living from dead, but it won’t decide things based on cooldown availability, your health, target health, resource availability, etc… you need to provide those kind of smarts.
The “!” isn’t a priority thing its an “on only” if the spell is an on-off and there are very few spells that it can be used with.
For example is you have a simple macro like this for the Mage Ice Block ability
#showtooltip
/cast Ice Block
This will cast (turn on) Ice Block if its not already on and it will turn off Ice Block if it’s already on. Kind of dangerous if you have “happy fingers” and you accidentally double-tap the button.
First tap, turns on Ice Block (yeah I’m safe)
Happy-finger accidental second tap, turns off Ice Block (oh sh~t I’m going to die!!)
The “!” avoids the accidental turn off effect. If Ice Block is off, it turns it on. If its on, it doesn’t do anything and it stays on (IN YO FACE HAPPY FINGERS)
#showtooltip
/cast !Ice Block
Now the only way to turn off Ice Block is to wait for it expire, right-click the Ice Block Buff icon to cancel it, or use /cancelaura Ice Block or something like this
#showtooltip
/cast [mod]Ice Block;!Ice Block
Hold down a modifier key (alt, ctrl, shift) and Ice Block is activated normally (with the on-off effect). Don’t hold down a modifier key and Ice Block will only turn on.
Off the top of my head I can only think of Ice Block and Aspect of Turtle that “!” works with, but I imagine that every class has maybe 1 ability that could use it.
See here for more info
https://wow.gamepedia.com/Macro_commands
https://wow.gamepedia.com/MACRO_cast
https://wow.gamepedia.com/Macro_conditionals
https://wow.gamepedia.com/UnitId