We can then take a factor of $x$ out the first bracket to leave us
with
$x(1 + x + x^2 + x^3+\ldots)^2$
Using the geometric sum given in the question, this comes to
$$x\times \left(\frac{1}{1-x}\right)^2 = \frac{x}{(1-x)^2}$$
__
A similar method could be used for the series $x + 4x^2 + 9x^3 +
16x^4 +\ldots$, factorising it as $(x + 3x^2 + 5x^3 +
7x^4+\ldots)(1 + x + x^2 + x^3 +\ldots)$, then writing the left
hand bracket as $(x + x^2 + x^3+\ldots + 2x^2 + 4x^3 +
6x^4+\ldots)$, from which point we can use our previous sum to
obtain an answer. Unfortunately this doesn't generalise easily into
higher powers, the amount of working needed growing much larger at
each stage.
A more elegant solution is differentiation. If we differentiate our
first series, we get $1 + 4x + 9x^2 + 16x^3+\ldots +
n^2x^{n-1}+\ldots$. Multiplying through by $x$ gives us $x + 4x^2 +
9x^3+\ldots + n^2 x^n+\ldots$, which is the $n^2 x^n$ series we
need.
If $x + 2x^2 + 3x^3 + 4x^4+\ldots = x/(1-x)^2$ then $x(d[x + 2x^2 +
3x^3+\ldots]/dx) = x(d[x/(1-x)^2]/dx)$.
But the left-hand side is equal to $x + 4x^2 + 9x^3 + 16x^4
+\ldots$, the sequence we want to sum.
We can resolve the right-hand using the quotient rule, and it comes
to $x(1+x)/(1-x)^3$.
Therefore $x d[x + 4x^2 + 9x^3+\ldots]/dx = x + 8x^2 +
27x^3+\ldots$, our next sequence. We can differentiate the previous
infinite sum and multiply by $x$ at each stage to get the sum for
the next power, and by applying the same process to the closed-form
expression, we can obtain a closed-form expression for the next
power.