Think of the balls, urns as being labelled. That does not affect the probabilities.
There are $m^n$ equally likely ways to distribute the $n$ objects among the $m$ urns.
Call a distribution good if at most $2$ urns contain balls. We count the good distributions.
These are of two types (i) all the balls end up in one urn and (ii) the balls end up in two urns.
It is clear that there are $\binom{m}{1}$ type (i) distributions.
For type (ii), there are $\binom{m}{2}$ ways to choose the two lucky urns. There are $2^n-2$ ways to distribute the balls among the $2$ urns so that neither urn is empty. So the number of distributions of type (ii) is $\binom{m}{2}(2^n-2)$.
Add to find the number of good distributions.