It depends on what you mean by "square" and it's basically a problem of notation. When you write $\left(\frac{d^2}{{dx}^2}\right)^2 $, implicitly the "square" means that you compose the operator $\frac{d^2}{{dx}^2}$ with itself, i.e. you consider $\frac{d^2}{{dx}^2} \circ \frac{d^2}{{dx}^2}$. This is of course equal to $\frac{d^4}{{dx}^4}$: differentiating four times is the same thing as differentiating twice then differentiating twice again. Applied to some function $f$, this then gives $\frac{d^2}{{dx}^2} \left( \frac{d^2 f(x)}{{dx}^2} \right) = \frac{d^4 f(x)}{{dx}^4}$, which is true.
On the other hand, where you write $\left(\frac{d^2 f(x)}{{dx}^2}\right)^2$, the "square" is implicitly multiplication, i.e. you're considering $\left(\frac{d^2 f(x)}{{dx}^2}\right) \cdot \left(\frac{d^2 f(x)}{{dx}^2}\right)$. This is not equal to the first thing, as simple counterexamples show (e.g. $f(x) = x^3$: $f''(x) = 6x$ thus $(d^4f)/(dx^4)(x) = 0$ while $((d^2f)/(dx^2)(x))^2 = (6x)^2 = 36x^2$). So you need to be careful with your notations.