To find the indefinite integral I will make use of the so-called reverse quotient rule (For another example using this method see here).
Recall that if $u$ and $v$ are differentiable functions, from the quotient rule
$$\left (\frac{u}{v} \right )' = \frac{u' v - v' u}{v^2},$$
it is immediate that
$$\int \frac{u' v - v' u}{v^2} \, dx = \int \left (\frac{u}{v} \right )' \, dx = \frac{u}{v} + C. \tag1$$
Writing the integral as
$$I = \int \left (\frac{\arctan (x)}{\arctan (x) - x} \right )^2 \, dx = \int \frac{\arctan^2 (x)}{(\arctan (x) - x)^2} \, dx,$$
we see that $v = \arctan (x) - x$. So $v' = -x^2/(1 + x^2)$. Now for the hard bit. We need to find a function $u(x)$ such that
$$u' v - v' u = u'(\arctan (x) - x) + u \frac{x^2}{1 + x^2} = \arctan^2 (x).$$
After a little trial and error we find that if
$$u = x\arctan (x) + 1,$$
as
$$u' = \arctan (x) + \frac{x}{1 + x^2},$$
then
$$u' v - v' u = \arctan^2 (x),$$
as required.
Our integral can now be readily found as it can be rewritten in the form given by (1). The result is:
$$I = \int \left (\frac{x \arctan (x) + 1}{\arctan (x) - x} \right )' \, dx = \frac{x \arctan (x) + 1}{\arctan (x) - x} + C.$$