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.
Note that $b^2\equiv 0~({\rm mod~}4)$ if $b$ is even, and $b^2\equiv 1~({\rm mod~}4)$ if $b$ is odd. Since $D$ and $b$ can be made of the same parity, the assumption on $D$ shows that $D\equiv b^2~({\rm mod ~}4).$
To complete the result that $D\equiv b^2~({\rm mod~}4m),$ just note that $m$ is odd, so $D\equiv b^2~({\rm mod~}m)$ and $D\equiv b^2~({\rm mod~}4)$ together give the result.