I am integrating
$$\pi\int\left(\cfrac{1}{x^2+4}\right)^2dx$$
I understand I need to integrate by parts. But why is it that $$u=\cfrac{1}{x^2+4}$$ and not $$u=\left(\cfrac{1}{x^2+4}\right)^2$$
How to account for the exponent of 2?
I am integrating
$$\pi\int\left(\cfrac{1}{x^2+4}\right)^2dx$$
I understand I need to integrate by parts. But why is it that $$u=\cfrac{1}{x^2+4}$$ and not $$u=\left(\cfrac{1}{x^2+4}\right)^2$$
How to account for the exponent of 2?
I think that you misunderstood the solution.
Starting from $\int \frac{1}{x^2+4} dx$ and integrating by parts you get $$\int \frac{1}{x^2+4} dx =\frac{x}{x^2+4} +\int \frac{2x^2}{(x^2+4)^2} dx\\ \int \frac{1}{x^2+4} dx=\frac{x}{x^2+4} +\int \frac{2x^2+8}{(x^2+4)^2} -8\int \frac{1}{(x^2+4)^2} dx\\ 8\int \frac{1}{(x^2+4)^2} dx=\frac{x}{x^2+4} +\int \frac{1}{x^2+4} dx\\ $$
This is a pretty standard technique to get a recurrence relation for $\int\frac{1}{(x^2+4)^n} dx$.
You may like this method. Since
$$ \int\frac{1}{x^2+a^2}dx=\frac{1}{a}\arctan(\frac xa)+C, $$
then differentiating the above gives $$ \int\frac{-2a}{(x^2+a^2)^2}dx=-\frac{1}{a^2}\bigg[\arctan(\frac xa)+\frac{ax}{x^2+a^2}\bigg], $$ and hence $$ \int\frac{1}{(x^2+a^2)^2}dx=\frac{1}{2a^3}\bigg[\arctan(\frac xa)+\frac{ax}{x^2+a^2}\bigg]+C. $$
Then set $a=2$.
You account for the exponent by setting $v'=\frac1{x^2+4}$. This makes $\int u\cdot v'\,dx$ into your integral, and you can use integration by parts to advance.
As for why it is that $u=\frac1{x^2+4}$ and not something else, there is no formal, rigorous reason. Presumably, that choice just happens to give you an integral you can actually solve. (I haven't actually sat down and checked for myself whether that is indeed the way to go.) That's the way it usually is with integration: It can be difficult to pin down exactly what works and why, is mostly a matter of trial and error, perseverance and experience.
I would avoid integration by parts and instead try substitution. $$\pi\int\left(\cfrac{1}{x^2+4}\right)^2dx$$
$$x=2\tan t$$ will change your integral to $$\pi \int \frac {2\sec ^2 t dt }{16 \sec ^4 t }= (\pi/8) \int\cos ^2t dt$$