Hint: $\bmod I\!: \overbrace{\color{#c00}x\equiv x^{-1}\equiv \color{#0a0}{x^2}}^{\textstyle x\cdot \color{#c00}x\ \equiv\ 1\ \equiv\ x\cdot \color{#0a0}{x^2}}\!\!\! $ (by $\,{-1} = 1\,$ in $\Bbb Z_2,\,$ and uniqueness of inverses)
Alternatively: $\, x^{\large \color{#0a0}2}\equiv 1\equiv x^{\large\color{#0a0}3}\Rightarrow x\,$ has order $\,\color{#c00}{n\!=\!1}\,$ (by $\,n\mid\color{#0a0}{ 2,3})$ so $\,x^{\large \color{#c00}1}\equiv 1\Rightarrow x^2\equiv x $
Remark $ $ Generally the most efficient way to verify ideal membership $\,f\in (g_1,\ldots,g_n) = I\,$ in a Euclidean domain is to compute the generator $\,g\,$ of the ideal $I = (g)$ by the Euclidean algorithm, then $\,f\in (g)\iff g\mid f\,$ so ideal membership reduces to a divisibility test. Doing so here, over the coefficient ring $\,R=\Bbb Z_2,\,$ we compute
by Euclid: $\,(g) = (x^2\!-1,\,x^3\!-1) = (x\!-\!1),\,$ hence $\,f\in (g)\!=\!(x\!-\!1)R[x]\!\iff\! x\!-\!1\mid f\,\ {\rm in}\ R[x]$ $\!\iff\! f(1) = 0\,$ in $R=\Bbb Z_2\!\iff 2\mid f(1)\,\ {\rm in}\,\ \Bbb Z$.
In special cases like the OP there may be easier methods, e.g. as above. Without further context it is not clear which of these the exercise was meant to illustrate (but all are useful to know in general)
There are some generalizations to multivariate polynomials, e.g. see the Gröbner basis algorithm (which may be viewed both as a multivariate generalization of the (Euclidean) polynomial division algorithm, as well as a nonlinear generalization of Gaussian elimination for linear systems of equation). A nice example is Gauss's constructive algorithm to rewrite a symmetric polynomial as a polynomial in the elementary symmetric polynomials, yielding a constructive interpretation of the Fundamental Theorem of Symmetric Polynomials.