We have the equation
$$n^2 + (n+1)^2 = m \tag{1}\label{eq1A}$$
for positive integers $n$ and $m$. Since $\gcd(n,n+1) = 1$, then $\gcd(n,m)=\gcd(n+1,m)=1$ as well. Next, consider if there's a prime factor $p \equiv 3 \pmod{4}$ which divides $m$. Then $n$ has a multiplicative inverse modulo $p$, call it $n^{-1}$, so \eqref{eq1A} becomes
$$(n+1)^2 \equiv -n^2 \pmod{p} \; \to \; (n^{-1}(n+1))^2 \equiv -1 \pmod{p} \tag{2}\label{eq2A}$$
Thus, $-1$ would be a quadratic residue modulo $p$. However, as shown in If p $\equiv$ 3 (mod 4) with p prime, prove -1 is a non-quadratic residue modulo p., this is not possible. Thus, all prime factors of $m$ are congruent to $1$ modulo $4$.
Next, the sum of squares function for $k=2$ states that
The prime factorization $n=2^{g}p_{1}^{f_{1}}p_{2}^{f_{2}}\cdots q_{1}^{h_{1}}q_{2}^{h_{2}}\cdots$, where $p_{i}$ are the prime factors of the form $p_{i}\equiv 1\pmod {4}$ and $q_{i}$ are the prime factors of the form $q_{i}\equiv 3\pmod {4}$ gives another formula
$\qquad r_{2}(n)=4(f_{1}+1)(f_{2}+1)\cdots$, if all exponents $h_{1},h_{2},\cdots$ are even. If one or more $h_{i}$ are odd, then $r_{2}(n)=0$.
Note $r_2(n)$ is the number of representations of $n$ as a sum of $2$ squares, and their $n$ is the $m$ in \eqref{eq1A}. Since $m$ is odd, then $g = 0$. As explained earlier, all $h_i = 0$. Also, since there are $2$ additional lattice points in each of the other $3$ quadrants, there's a total of exactly $8$ lattice points. Thus, $r_2(m) = 8$, so $f_1 = 1$ and $f_i = 0$ for all $i \gt 1$. This gives $m = r^2 = p_1$, i.e., it's a prime.