Example 3 Given that the center of the hyperbola is at the origin, the foci are on the $x$-axis, and the hyperbola is tangent to the lines $2 x-y+\sqrt{21}=0$ and $x+y+\sqrt{3}=0$. Find the equation of this hyperbola.
Solution: Let the two foci of the hyperbola be $F_{1}(-c, 0)$, $F_{2}(c, 0)$, and the imaginary semi-axis length be $b$,
$\because$ The line $2 x-y+\sqrt{21}=0$ is tangent to the hyperbola,
$$\therefore\left\{\begin{array}{l}
(-2 c+\sqrt{21})(2 c+\sqrt{21})<0 \\
\frac{|-2 c+\sqrt{21}|}{\sqrt{5}} \cdot \frac{|2 c+\sqrt{21}|}{\sqrt{5}}=b^{2}
\end{array}\right.$$

which means $5 b^{2}=4 c^{2}-21$.
Similarly, $\left\{\begin{array}{l}(-c+\sqrt{3})(c+\sqrt{3})<0 \\ \frac{|-c+\sqrt{3}|}{\sqrt{2}} \cdot \frac{|c+\sqrt{3}|}{\sqrt{2}}=b^{2}\end{array}\right.$.
which means $2 b^{2}=c^{2}-3$.
From (1) and (2), we get,
$$b^{2}=3, c^{2}=9, \therefore a^{2}=6 \text {. }$$
$\therefore$ The equation of the hyperbola is $\frac{x^{2}}{6}-\frac{y^{2}}{3}=1$.