Because:
A) for odd $x$ and $x \equiv 1\pmod {4}$ the upper formula is the same as $x - (x-1)/4$
B) for odd $x$ and $x \equiv 3\pmod {4}$ the upper formula is the same as $(x + 1)/4$
Example A) ((17-1)/2)^2 mod 17 = 13 or 17-16/4=13 , 17 mod 4 = 1
Example B) ((19-1)/2)^2 mod 19 = 5 or (19+1)/4=5 , 19 mod 4 = 3
This question is closely connected with square residues or to be more precise with "centered" square residues! reformulation of square residues for odd numbers? Example for 25:25-(25-1)/4 = 19