Could someone please explain why we use a conversion formula for solving logs which are not of base 10 or e.

I don't understand what the formula is or where it comes from.

Formula: $\displaystyle log b M = \frac{log a M}{log a b} $

How can I also use latex to make something "the base"

Thanks!