Example 8 Let the lengths of the two legs of a right triangle be $a$ and $b$, and the length of the hypotenuse be $c$. If $a$, $b$, and $c$ are all integers, and $c=\frac{1}{3} a b-(a+b)$, find the number of right triangles that satisfy the condition. ${ }^{(6)}$
(2010, National Junior High School Mathematics Competition, Tianjin Preliminary Contest)
【Analysis】In a right-angled triangle, the three sides satisfy the Pythagorean theorem. Given the condition $c=\frac{1}{3} a b-(a+b)$, one unknown can be eliminated to obtain a quadratic equation in two variables, which is generally difficult to solve. However, the problem of integer solutions to a quadratic equation in two variables can be handled through factorization.
By the Pythagorean theorem, we have $c^{2}=a^{2}+b^{2}$.
Substituting $c=\frac{1}{3} a b-(a+b)$ into the above equation, we get
$$
\begin{array}{l}
a^{2}+b^{2} \\
=\frac{1}{9}(a b)^{2}-\frac{2}{3} a b(a+b)+a^{2}+2 a b+b^{2} .
\end{array}
$$

Simplifying, we get
$$
\begin{array}{l}
a b-6(a+b)+18=0 \\
\Rightarrow(a-6)(b-6)=18=1 \times 18=2 \times 9=3 \times 6 .
\end{array}
$$

Since $a$ and $b$ are both positive integers, we can assume without loss of generality that $a<b$.
Solving, we get
$$
(a, b, c)=(7,24,25),(8,15,17),(9,12,15) \text {. }
$$

Thus, there are three right-angled triangles that satisfy the conditions.