this proof relies on two facts (the proof of these two facts is another story):
1) $\log_a(x) - \log_a(y) = \log_a(\frac{x}{y})$
2) $a^x = y$ when $\log_a(y) = x$ <--this is really saying $\log_a$ is 1-1, more on that later.
(this is often given as the definition of log (base a) of y: the number you have to exponentiate a by to get y).
now if:
$\log_a(x) = \log_a(y)$
$\log_a(\frac{x}{y}) = \log_a(x) - \log_a(y) = 0$
so:
$a^{\log_a(\frac{x}{y})} = a^0$
that is:
$\frac{x}{y} = 1$
which means:
$x = y$.
to be honest, there's a degree of "circularity" in this argument: we use the fact that $\log_a$ is an inverse function to exponentiation by a (functions with inverses have to be 1-1). to avoid that, we need a better definition of $\log_a$.
the most "practical" definition (in terms of avoiding self-reference) is:
$$\log(x) = \int_1^x \dfrac{1}{t}\ dt$$
then one can PROVE that:
$\log(ab) = \log(a) + \log(b)$ (*)
and that $\log$ (note the absence of an indicated base) is an increasing function (and thus has an inverse) on $(0,\infty)$.
the proof of (*) is interesting, so i'll give it here:
$$\log(ab) = \int_1^{ab} \dfrac{1}{t}\ dt = \int_1^a \dfrac{1}{t}\ dt + \int_a^{ab} \dfrac{1}{t}\ dt = \log(a) + \int_a^{ab} \frac{1}{t}\ dt$$
to evaluate the second integral, we make a "u-substitution":
let $u = \dfrac{t}{a}$, so that $du = \dfrac{1}{a}\ dt$
as $t$ goes from $a$ to $ab$, $u$ goes from 1 to $b$ so:
$$\int_a^{ab} \frac{1}{t}\ dt = \int_1^b \frac{a}{au}\ du = \int_1^b \frac{1}{u}\ du = \log(b)$$
it should be clear that $\log$ defined this way is increasing, so it ought to have an inverse defined on its range (ignoring, for the moment, just what its range might be). let's call this function $g$.
suppose $x = \log(a)$, $y = \log(b)$ which means:
$g(x) = a, g(y) = b$.
then: $x + y = \log(a) + \log(b) = \log(ab)$, so:
$g(x+y) = g(\log(ab)) = ab = g(x)g(y)$.
so $g$ "acts like" it's some function $c^x$ for some $c$. what might $c$ be?
well, $c^1 = c$ so we should have:
$$1 = \log(c) = \int_1^c \frac{1}{t}\ dt$$
this only gives a definition of "log" (no base). can you figure out how you would get to "$\log_a$"(with a base)?
*******
as other have pointed out, $\log(f(x))$ may not be a 1-1 function. BUT...
if $\log \circ f = \log \circ g,\ \forall x \in \Bbb R$
we can conclude that:
$f(x) = g(x),\ \forall x \in \Bbb R$, hence $f = g$.
it could happen that $\log(f(x))$ is undefined, for certain $x$. in that case, we can only be sure that $f = g$ for those $x$ where the logs ARE defined. so sometimes one has to consider $|f(x)|$ and $|g(x)|$ instead.