Example 2 Factorize:
$$
(x y-1)^{2}+(x+y-2)(x+y-2 x y)
$$
Solution: Let $x+y=u, x y=v$, then
$$
\begin{array}{l}
\text { original expression }=(v-1)^{2}+(u-2)(u-2 v) \\
=v^{2}-2 v+1+u^{2}-2 u-2 u v+4 v \\
=(u-v)^{2}-2(u-v)+1 \\
=(u-v-1)^{2} \\
=(x+y-x y-1)^{2} \\
=(x-1)^{2}(y-1)^{2} .
\end{array}
$$