Example 3 Find the values of $a$ and $b$ such that the polynomial
$$
x^{4}+(2 a+1) x^{3}+(a-1)^{2} x^{2}+b x+4
$$

can be factored into the product of two quadratic polynomials $P(x)$ and $Q(x)$ with leading coefficients of 1, and
(1) $P(x)=0$ has two distinct real roots $r$ and $s$;
(2) $\boldsymbol{Q}(r)=s, Q(s)=r$.
(1991, Sichuan Province High School Mathematics Competition)
Solution: From (1), let
$$
\begin{aligned}
P(x) & =x^{2}+u x+v \\
& =x^{2}-(r+s) x+r s .
\end{aligned}
$$

Let $Q(x)=x^{2}+w x+t$, then from (2) we have
$$
\left\{\begin{array}{l}
r^{2}+w r+t=s, \\
s^{2}+w s+t=r .
\end{array}\right.
$$

Solving, we get $\left\{\begin{array}{l}w=-(r+s+1) \\ t=r s+r+s .\end{array}\right.$,
From (1), we have $r+s=-u, r s=v$. Substituting into (2), we get
$$
\begin{array}{l}
w=u-1, t=v-u . \\
\therefore Q(x)=x^{2}+(u-1) x+v-u .
\end{array}
$$

From the given conditions, let
$$
\begin{array}{l} 
x^{4}+(2 a+1) x^{3}+(a-1)^{2} x^{2}+b x+4 \\
= P(x) \cdot Q(x) \\
=\left(x^{2}+u x+v\right)\left(x^{6}+(u-1) x+u-u\right] \\
= x^{4}+(2 u-1) x^{2}+\left(u^{2}-2 u+2 v\right) x^{2} \\
-\left(u^{2}-2 u v+v\right) x+v(v-u) .
\end{array}
$$

Comparing the coefficients of like terms on both sides of the equation, we get
$$
\left\{\begin{array}{l}
2 u-1=2 a+1, \\
u^{2}-2 u+2 v=(a-1)^{2}, \\
u^{2}-2 u v+v=-b, \\
v(v-u)=4 .
\end{array}\right.
$$

Solving this system of equations, we get
$$
a=2, b=-14 \text { or } a=-1, b=-2 \text {. }
$$