<s>[INST] Let $D,m$ be relatively prime integers with $m$ odd. Then $D \equiv 0,1 \pmod 4$ and $D \equiv b^2 \pmod m$ implies that $D \equiv b^2 \pmod{4m}$ This is from a proof in David A. Cox's Primes of the Form $x^2+ny^2$:

Lemma 2.5 Let $D\equiv 0,1 \bmod 4$ be an integer and $m$ be an odd integer relatively prime to $D$.  Then $m$ is properly represented by a primitive form of discriminant $D$ if and only if $D$ is a quadratic residue modulo $m$.


Proof: If $f(x,y)$ properly represents $m$ then by Lemma 2.3, we may assume $f(x,y) = mx^2 + bxy + cy^2$. Thus $D=b^2-4mc$, and $D\equiv b^2 \bmod m$ follows immediately.


$\;\;\;\;$ Conversely, suppose that $D\equiv b^2 \bmod m$.  Since $m$ is odd, we can assume that $D$ and $b$ have the same parity (replace $b$ by $b+m$ if necessary), and then $D\equiv 0,1 \bmod 4$ implies that $D\equiv b^2 \bmod 4m$. $[\ldots]$

I cannot see how, in the third paragraph,  $D \equiv b^2 \pmod{4m}$ follows. I tried doing examples to get an intuition for why it holds, but I cannot figure out why. Any help is appreciated.
 [/INST] I don't think this holds unless we assume $b$ is odd. Let $D=81$ and $m=45$. Then $(D \pmod {45}) =36=6^2$ but $(D \pmod {4×45})=81=36+49$ $=36+m$.
If on the other hand $D \pmod m$ is an odd square $b^2$, then because both $D$ and $m$ are odd, it follows that the equation $D=b^2+km$ must hold for an integer $k$ that must be even. But the fact that $D \pmod 4 = b^2 \pmod 4$ implies that $km$ must in fact be a multiple of $4$, which implies $k$ must be a multiple of $4$. Thus $D=b^2+km$ for some $k$ which is a multiple of $4$, which gives $D = b^2+c(4m)$, where $c$ is the integer such that $k=4c$. In particular, as $D=c(4m)$ for some integral $c$, it follows that $D \pmod{4m} = b^2$ as well.
</s>