Example 1 Let $a^{2}+1=3 a, b^{2}+1=3 b, \mathrm{H} a \neq b$. Then the value of the algebraic expression $\frac{1}{a^{2}}+\frac{1}{b^{2}}$ is ( ).
(A) 5
(B) 7
(C) 9
(D) 11
From the given conditions, we have
$$
a^{2}-3 a+1=0, b^{2}-3 b+1=0 \text {, and } a \neq b \text {. }
$$

Then \(a\) and \(b\) are the roots of the quadratic equation
$$
x^{2}-3 x+1=0
$$

Therefore, by Vieta's formulas, we get
$$
\begin{array}{l}
a+b=3, a b=1 . \\
\text { Hence } \frac{1}{a^{2}}+\frac{1}{b^{2}}=\frac{a^{2}+b^{2}}{a^{2} b^{2}}=\frac{(a+b)^{2}-2 a b}{(a b)^{2}}=7 .
\end{array}
$$

Therefore, the answer is B.