Issue is likely the button you have it on not the macro.
Unitframes eat mouse clicks. So, if you have them bound to a mouse button, that’s the problem. You’ll need an addon like Clique or to use Blizz’s click casting interface to get around it.
That said, your macros could benefit from using this template so you can also cast the spells on your target in addition to mouseover.