Example 10 Let $x, y, z$ be positive real numbers, and satisfy $x y z + x + z = y$, find
$$
p=\frac{2}{x^{2}+1}-\frac{2}{y^{2}+1}+\frac{3}{z^{2}+1}
$$

the maximum value.
From the given conditions, we have
$$
x+z=(1-x z) y,
$$

Clearly, $1-x z \neq 0$, so $y=\frac{x+z}{1-x z}$.
This reminds us of the tangent addition formula, so let
$$
\alpha=\arctan x, \beta=\arctan y, \gamma=\arctan z, \alpha, \beta, \gamma \in\left(0, \frac{\pi}{2}\right),
$$

Then
$$
\tan \beta=\frac{\tan \alpha+\tan \gamma}{1-\tan \alpha \tan \gamma}=\tan (\alpha+\gamma) .
$$

Since $\beta, \alpha+\gamma \in(0, \pi)$, we have $\beta=\alpha+\gamma$. Therefore,
$$
\begin{aligned}
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{aligned}
$$

Equality holds when $2 \alpha+\gamma=\frac{\pi}{2}, \sin \gamma=\frac{1}{3}$, i.e., $x=\frac{\sqrt{2}}{2}, y=\sqrt{2}, z=\frac{\sqrt{2}}{4}$. Therefore, the maximum value we seek is $\frac{10}{3}$.