Subtract $ \dfrac{2}{x+1} $ from $ \dfrac{x+2}{x^2-1} $ to get $ \dfrac{ \color{purple}{ -x+4 } }{ x^2-1 }$.
To subtract raitonal expressions, both fractions must have the same denominator.
We can create a common denominator by multiplying the second fraction by $\color{blue}{x-1}$.
$$ \begin{aligned} \frac{x+2}{x^2-1} - \frac{2}{x+1} & = \frac{ x+2 }{ x^2-1 } - \frac{ 2 \cdot \color{blue}{ \left( x-1 \right) }}{ \left( x+1 \right) \cdot \color{blue}{ \left( x-1 \right) }} = \\[1ex] &=\frac{ \color{purple}{ x+2 } }{ x^2-1 } - \frac{ \color{purple}{ 2x-2 } }{ x^2-1 }=\frac{ \color{purple}{ x+2 - \left( 2x-2 \right) } }{ x^2-1 } = \\[1ex] &=\frac{ \color{purple}{ -x+4 } }{ x^2-1 } \end{aligned} $$