Example 1 Let $a, b, c > 0$, and $abc + a + c = b$. Find the maximum value of
$$
p=\frac{2}{a^{2}+1}-\frac{2}{b^{2}+1}+\frac{3}{c^{2}+1}
$$
(1999, Vietnam Mathematical Olympiad)
From the given conditions, we have
$$
a+c=(1-a c) b \text{. }
$$

Obviously, $1-a c \neq 0$. Therefore, $b=\frac{a+c}{1-a c}$.
Let $\alpha=\arctan a, \beta=\arctan b, \gamma=\arctan c$, where $\alpha, \beta, \gamma \in\left(0, \frac{\pi}{2}\right)$.
Then $\tan \beta=\frac{\tan \alpha+\tan \gamma}{1-\tan \alpha \cdot \tan \gamma}=\tan (\alpha+\gamma)$.
Since $\beta, \alpha+\beta \in(0, \pi)$, thus, $\beta=\alpha+\gamma$.
$$
\begin{array}{l}
\text { Hence } p=\frac{2}{\tan ^{2} \alpha+1}-\frac{2}{\tan ^{2} \beta+1}+\frac{3}{\tan ^{2} \gamma+1} \\
=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 \cdot \sin (2 \alpha+\gamma)+3 \cos ^{2} \gamma \\
\leqslant 2 \sin \gamma+3\left(1-\sin ^{2} \gamma\right) \\
=-3\left(\sin \gamma-\frac{1}{3}\right)^{2}+\frac{10}{3} \\
\leqslant \frac{10}{3} .
\end{array}
$$

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}$, the equality in (1) holds.
Thus, $p_{\text {max }}=\frac{10}{3}$.
[Note] For certain special algebraic expressions or constraint conditions, using trigonometric substitution is an effective method of solving problems.