I get confused very often about the operations I am allowed to perform on the generators of an ideal such that the set still generates the ideal (usually getting confused with $R$-module bases using linear combinations). So for example, if I wanted to simplify $\langle x^2+1, x+1\rangle \trianglelefteq \mathbb{Z}[x]$. I showed that $2\in \langle x^2+1, x+1\rangle$ and $x^2+1 \in \langle 2, x+1\rangle$. Is this enough to show they are equal? What other operations are allowed?
Another example I can think of is $\langle a,b\rangle = \langle a,b-a\rangle$.
If $I=\langle{A}\rangle$ and $J=\langle{B}\rangle$, then $I=J$ if and only if $A\subseteq J$ and $B\subseteq I$.
Proof:
Suppose$\;I=J$.$\;$Then
$\qquad I=\langle{A}\rangle\implies A\subseteq I\implies A\subseteq J$
$\qquad J=\langle{B}\rangle\implies B\subseteq J\implies B\subseteq I$
Conversely, suppose$\;A\subseteq J\;\text{and}\;B\subseteq I$.$\;$Then
$\qquad A\subseteq J\implies \langle{A}\rangle\subseteq J\implies I\subseteq J$
$\qquad B\subseteq I\implies \langle{B}\rangle\subseteq I\implies J\subseteq I$
hence$\;I=J$.
Applying the above principle to your example . . .
In the ring $\mathbb{Z}[x]$, let $I=\langle{x^2+1,x+1}\rangle$ and $J=\langle{2,x+1}\rangle$.
Then to show $I=J$, it suffices to show $x^2+1\in J$ and $2\in I$.
$\qquad$From $x^2+1=(x+1)^2-2x$, it follows that $x^2+1\in J$.
$\qquad$From $2=2(x+1)-\bigl((x+1)^2-(x^2+1)\bigr)$, it follows that $2\in I$.
Therefore $I=J$.
The equality $\langle a,b\rangle = \langle a,b-a\rangle$ can be verified in the same way.