Why does this formula work?
The bond with greater electronegativity difference has greater tendency to break with help of polar $\ce{H2O}$ molecules to hydrated ions, unless it is ionic already. Electrons then stay at the oxygen as the most electronegative atom from all the three.
So if $\ce{M}$ is less electronegative then $\ce{H}$, there will be'
$$\ce{M^{(+)}-O^{(-)}-H(aq) &lt;=&gt; M+(aq) + OH-(aq)}$$
but if $\ce{M}$ is more electronegative than $\ce{H}$ , then there will be:
$$\ce{M-O^{(-)}-H^{(+)}(aq) + H2O &lt;=&gt; MO-(aq) + H3O+(aq)}$$
( The charge in parenthesis is a partial charge.)