Solution 1:

For your first question, if we suppose that $a, b \geq 2$ and $k$ are all fixed, then there are at most two solutions in positive exponents $m$ and $n$. This follows from lower bounds for linear forms in logarithms (and probably other approaches). As for Pillai's conjecture, it's wide open still (modulo developments on the ABC conjecture). It is still unknown, by way of example, whether there are only finitely many perfect powers differing by $2$.

Standard conjectures would imply that your function $f(d)$ is zero for "most" $d$ (if we agree to avoid $m=n=2$).