<s>[INST] An equivalent of Jacobi's two square theorem Jacobi's two square theorem:

The number of representations of $n$ as a sum of two squares is $4$ times the difference
  between the number of divisors of $n$ congruent to $1$ modulo $4$ and the number of divisors
  of $n$ congruent to $3$ modulo $4$.

This is equivalent to
$$\left(\sum_{n\in\mathbb{Z}}q^{n^2}\right)^2=1+4\sum_{n\ge 0}\left(\frac{q^{4n+1}}{1-q^{4n+1}}-\frac{q^{4n+3}}{1-q^{4n+3}}\right).$$
But why are these two theorems equivalent? What does the sum
$$\left(\sum_{n\in\mathbb{Z}}q^{n^2}\right)^2$$
have to do with ways of writing numbers as sums of two squares?
 [/INST] You remark about convergence in a comment.  Convergence is not relevant.  These series are recording combinatorial information in their coefficients.  They are formal power series, recording data in their coefficients.
Let us start with a smaller version of the last sum.
\begin{align*}
\sum_{n=-4}^4 q^{n^2}  
    &=  q^{(-4)^2} + q^{(-3)^2} + q^{(-2)^2} + q^{(-1)^2} + q^{0^2} + q^{1^2} + q^{2^2} + q^{3^2} + q^{4^2}  \\
    &=  q^{16} + q^{9} + q^{4} + q^{1} + q^{0} + q^{1} + q^{4} + q^{9} + q^{16}  \\
    &=  q^{0} + 2q^{1} + 2q^{4} + 2q^{9} + 2q^{16}  \text{.}
\end{align*}
What do we see?  The squares of the range of integers we are keeping appear as exponents.  The number of ways of writing one of these squares as a square of an integer appears as the coefficient.  So we should be able to see that the sum over all integers, which just extends this sum with more terms of the form $c q^s$ where $s$ is a square and $c=2$ is the number of integers squaring to $s$, records the combinatorial information that there are $c$ ways to express $s$ as the square of an integer.
What happens when we square this series?  We construct many terms of the form $c_1 q^{s_1} \cdot c_2 q^{s_2} = c_1 c_2 q^{s_1 + s_2}$, each representing that from the $c_1$ ways to express the square $s_1$ and the $c_2$ ways to express the square $s_2$, there are $c_1 c_2$ ways to express the sum of squares $s_1 + s_2$.  Let's perform the squaring of our fragment of the last series.
$$  \left( \sum_{n=-4}^4 q^{n^2} \right)^2 = q^0 + 4q + 4q^2 + 4q^4 + 8q^5 + 4 q^8 + 8 q^{10} + 8 q^{13} + 4 q^{16} + 8 q^{17} + 4 q^{18} + 8 q^{20} + 8 q^{25} + 4 q^{32}  $$
This says, among many other things, there are $8$ ways to write $5$ as the sum of two squares of integers from $[-4,4]$.  Looking at the source of that term,
$$  8 q^5 = 2q^1 \cdot 2q^4 + 2q^4 \cdot 2q^1  \text{,}  $$
we can read off that the eight ways of writing $5$ in this manner are \begin{align*}
2^2 &+ 1^2,  &  2^2 &+ (-1)^2,  &  (-2)^2 &+ 1^2,  &  (-2)^2 &+ (-1)^2  \\
1^2 &+ 2^2,  &  1^2 &+ (-2)^2,  &  (-1)^2 &+ 2^2,  &  (-1)^2 &+ (-2)^2  \text{.}
\end{align*}
</s>