Your binding does successfully run the keyboard macro you've specified.
The problem is that the resulting message does not remain in the echo area long enough for you to see it, which is a side-effect of invoking the command via a keyboard macro (you will see the same problem if you record the macro with <f3>C-uM-=<f4>).
If you open the messages buffer with C-he and then use your binding again, you'll see the message being generated.
Is this because M-=
is an interactive function?
Your terminology is mixed up. M-=
is not a function. "M-="
is a keyboard macro representing the key sequence M-= which is bound to the interactive function count-words-region
.
(Note also that you cannot bind keys to non-interactive functions.)
Would I need a function to do this?
To get the behaviour you're looking for, yes (and djangoliv has provided the appropriate answer for that).