The points such as their orthogonal projection on the line $r$ is $M=(1,-1,1)$ lay on the plane that passes through that point $M$ and that is orthogonal to $r$.
First of all, then, I determined the directional vector of the line, which is (one can also write $r$ in parametric form and infer it): \begin{equation} \mathbf{v}_{r}=(1,1,0)\wedge(0,0,1)=\begin{vmatrix} \mathbf{i}&\mathbf{j}&\mathbf{k}\\1&1&0\\0&0&1\end{vmatrix}=(1,-1,0) \end{equation} This vector is parallel to the normal vector of the searched plane $\pi$. Thus, the Cartesian equation of $\pi$ is found via dot product. Precisely, I impose that the scalar product between the normal vector of the plane $\mathbf{n}$ and the direction of the vector linking a generic point $A=(x,y,z)$ of $\pi$ and $M$ is zero: \begin{equation} \pi:(x-1,y+1,z-1)\cdot(1,-1,0)=x-1-y-1+0=x-y-2=0 \end{equation} The point I'm looking for is given by the intersection of $\pi$ and $r$. Hence, I write $r$ in parametric form and substitute in the equation of $\pi$: \begin{equation} r:\begin{cases} x=t\\y=-t\\z=1 \end{cases} \end{equation} Substituting in $\pi$ gives: $t+t-2=0\Rightarrow t=-1$.
In conclusion I find the point $P=(-1,1,1)$ whereas $\mathbf{\text{the correct solution is } P=(2,0,0)}$.
What did I do wrong?

Somewhere after calculating the expression for $\pi$, I lost you: you say that $P$ is the intersection of $\pi$ and $r$, so in particular you demand that $P$ must be a point on $r$, which it is not. This is your only mistake. But, you have done all the work: from $\pi: x-y=2$ and the fact that $P$ lies on the x-axis, i.e. $P=(x,0,0)$ you can conclude immediately that $x=2$.