Congruence of Squares for Factoring
The  assertion is not correct in general, as you have discovered.

However, here is what is correct:  $\gcd(x+y,n)$ is a factor  of $n$, and $\gcd(x-y,n)$ is a factor  of $n$.  Why?  Well, this is trivial: $\gcd(\text{anything},n)$ is always a  factor of $n$.  Of course, the gcd might be 1, but that's still a divisor of $n$.

We can say even more.   If we let $r=\gcd(x+y,n)$ and $s=\gcd(x-y,n)$, then their product is a multiple of $n$: i.e., $rs$ is a multiple of $n$.  Thus, you can replace $s$ with $s'=n/r$ and now $r,s'$ will have the property you want: both $r$ and $s'$ are divisors of  $n$, and $rs'=n$.  (Why is $rs$ a multiple of $n$? Because if  $x^2  \equiv y^2 \pmod n$, then it follows that $x^2 - y^2 \equiv 0 \pmod n$.  Now $x^2-y^2 = (x-y)(x+y)$, so it follows that $n$ divides $(x-y)(x+y)$, i.e., $n$ divides $rs$.)

This makes this method useful for factoring.  However, beware that there is no guarantee that get a non-trivial factor out of this.  For instance, consider $n=15$.   Then if $x=8$ and $y=7$, we have $x^2 \equiv y^2 \equiv 4 \pmod n$, but $\gcd(x-y,n)=1 $ and $\gcd(x+y,n)=15$, so we obtain that $15 = 1 \times 15$ -- true, but not very useful for factoring $n$.  What we can say is that if $n$  is the product of two large primes, and if you can randomly sample  two $x,y$ such that $x^2 \equiv y^2 \pmod n$, then with probability about $1/2$, $\gcd(x-y,n)$ and $\gcd(x+y,n)$ will give you the full factorization of $n$.

If you want us to comment on an assertion it helps to give a reference for it.  My guess would be that there is additional context you are not  providing, such as the assumption that $n$ is a product of two primes.