Example 16 Consider the equation in $x$
$$
x^{2}+\left(\frac{a}{x}\right)^{2}-7 x-\frac{7 a}{x}+2 a+12=0
$$

has two equal real roots. Find the value of $a$.
(1995, Huanggang Region, Hubei Province Junior High School Mathematics Competition)
(1) The equation can be rewritten as $\left(x+\frac{a}{x}\right)^{2}-7\left(x+\frac{a}{x}\right)+12$ $=0$, which gives $\left(x+\frac{a}{x}-4\right)\left(x+\frac{a}{x}-3\right)=0$, meaning $x+\frac{a}{x}$ $-4=0$ or $x+\frac{a}{x}-3=0$. Therefore, we have $x^{2}-4 x+a=0$ or $x^{2}-3 x+a=0$. Clearly, when $a=4$ or $a=\frac{9}{4}$, the original equation has two equal real roots $x_{1}=x_{2}=2$ or $x_{3}=x_{4}=\frac{3}{2}$.