Example 15 Let $a, b, c$ be positive real numbers, and $a b c + a + c = b$, find the maximum value of $p=\frac{2}{a^{2}+1}-\frac{2}{b^{2}+1}+\frac{3}{c^{2}+1}$.
Solution: Let $a=\tan \alpha, b=\tan \beta, c=\tan \gamma, \alpha, \beta, \gamma \in$ $\left(0, \frac{\pi}{2}\right)$

From $a b c+a+c=b$, we get $b=\frac{a+c}{1-a c}$, which means $\tan \beta=$ $\tan (\alpha+\gamma)$, thus $\beta=\alpha+\gamma$.

Therefore, $p=2 \cos ^{2} \alpha-2 \cos ^{2}(\alpha+\gamma)+3 \cos ^{2} \gamma=$ $\cos 2 \alpha+1-\cos (2 \alpha+2 \gamma)-1+3 \cos ^{2} \gamma$
$=2 \sin \gamma \sin (2 \alpha+\gamma)+3 \cos ^{2} \gamma \leqslant 2 \sin \gamma+$ $3 \cos ^{2} \gamma=3-3 \sin ^{2} \gamma+2 \sin \gamma \leqslant \frac{10}{3}$.

Thus, when $2 \alpha+\gamma=\frac{\pi}{2}, \sin \gamma=\frac{1}{3}$, i.e., $a=\frac{\sqrt{2}}{2}, b$ $=\sqrt{2}, c=\frac{\sqrt{2}}{4}$, we have $p_{\text {max }}=\frac{10}{3}$.