[guided]The strategy: we do not need the oracle to tell us a specific square root; we need it to tell us a "different" one. By [the count of square roots modulo a semiprime](/theorems/1683), every quadratic residue $c$ modulo $N$ has exactly four square roots, and they split into two pairs $\{x, -x\}$ and $\{z, -z\}$. The pairs $\{x, -x\}$ and $\{z, -z\}$ differ at exactly one of the two primes $p, q$ under the CRT decomposition.
Two of the four square roots reveal no information: the output $\pm x$ is something we already know. But the other two, $\pm z$, are related to $x$ by disagreement at exactly one prime. Concretely, $z - x$ is divisible by exactly one of $p, q$, so $\gcd(N, z - x)$ is that prime. This is a non-trivial factor.
Why do we sample $x$ uniformly at random? Because the oracle might be adversarial — it might even be designed to thwart our reduction. But conditional on the random variable $c = x^2 \bmod N$, the a posteriori distribution of $x$ over the four square roots of $c$ is uniform: given any sign vector $(\pm, \pm)$ in the CRT decomposition, the corresponding residue is equally likely to have been our original $x$. The oracle sees only $c$ (not $x$), so its output $y$ depends only on $c$. Therefore the event "$y \equiv \pm x \pmod N$" has conditional probability exactly $2/4 = 1/2$, and the event "$y \not\equiv \pm x \pmod N$" has conditional probability $1/2$. In the latter case, we factor.
Why does $\gcd(N, y - x)$ equal $p$ or $q$? Because $N \mid (y - x)(y + x)$ but $N \nmid (y - x)$ (since $y \not\equiv x \pmod N$) and $N \nmid (y + x)$ (since $y \not\equiv -x \pmod N$). The prime factorisation $N = pq$ forces each of $p, q$ to divide exactly one of the factors $y - x, y + x$. Therefore $\gcd(N, y - x) \in \{p, q\}$ — neither $1$ nor $N$.[/guided]