Let $[A]_0=a$ and $[B]_0=b$, then $[A]=a-x$ and $[B]=b-x$.
$$\int_0^x \frac{1}{(a-x)(b-x)}dx = \frac{1}{b-a}\left(\ln\frac{1}{a-x} - \ln\frac{1}{b-x}\right)$$
Evaluating the integral gives us:
$$\int_0^x \frac{1}{([A]_0-x)([B]_0-x)}dx = \frac{1}{[B]_0-[A]_0}\left(\ln\frac{[A]_0}{[A]_0-x} - \ln\frac{[B]_0}{[B]_0-x}\right)$$
In an assignment I have to mathematically prove a law in chemistry. Some of the math behind it can be seen in the above quote. However, I don't understand how they can replace the nummerators in the parenthesis with [A]o and [B]o. Is there any mathemathical/logical explanation to that? Is it due to that the whole fraction is equal to respectively [A]o and [B]o? Hope it makes sense..
It looks like a mysterious substitution, but actually what's happening is that there are additional terms that appear when you evaluate the complete definite integral. These extra terms contribute new terms to the numerator.
Let's take a look at the integrals involved. The indefinite integral of
$$f(x) = \frac{1}{(a-x)(b-x)}$$
is
$$F(x) = \int f(x)dx = \frac{1}{b-a}\left[\log\frac{1}{a-x} - \log\frac{1}{b-x}\right]$$
(which you can show using the method of partial fractions for integration).
In particular, we can evaluate the definite integral
$$\int_0^L f(x)dx = F(L) - F(0) = \frac{1}{b-a}\left[\log\frac{1}{a-L} - \log\frac{1}{b-L}\right] - \frac{1}{b-a}\left[\log\frac{1}{a} - \log\frac{1}{b}\right]$$
We can combine terms, then use the fact that $\log(p) - \log(q) = \log(p/q)$ to simplify the result:
$$= \frac{1}{b-a}\left[\left(\log\frac{1}{a-L} - \log\frac{1}{a}\right) - \left(\log\frac{1}{b-L} - \log\frac{1}{b}\right)\right]$$
$$= \frac{1}{b-a} \left[ \log\frac{a}{a-L} - \log\frac{b}{b-L}\right]$$
which is the result you're looking for.
Hope this helps!
P.S. I think the first equation in your question could have been more clearly written as an indefinite integral as shown below. (That is, writing $\int$ instead of $\int_0^x$). It might even have been a typo in the original. $$\int \frac{1}{(b-x)(a-x)}dx = \frac{1}{b-a}\left[\log\frac{1}{a-x} - \log\frac{1}{b-x}\right]$$