Carrying on from @AWashburn’s post:
$$f(x_1,x_2)=ax_1+bx_2+c\ \implies \\ a^2x_1+(ab+b^2)x_2+abx_3+(a+b+1)c\ =\ ax_1+bx_3+c$$
Comparing coefficients gives
$$\begin{array}{rcl} a^2 &=& a \\ ab+b^2 &=& 0 \\ ab &=& b \\ (a+b+1)c &=& c \end{array}$$
The first equation gives $a=0$ or $a=1$; the second gives $b=0$ or $a+b=0$ $\implies$ $b=-a=0\ \text{or}\ -\!1$. We have the following:
If $b=0$ then $(a+b+1)c=(a+1)c=c$ $\implies$ $a=1,c=0$ or $a=0,c=\ \text{any value}$. Hence $f(x_1,x_2)=x_1$ or $f(x_1,x_2)=c$ (constant).
If $b=-1$ then $(a+b+1)c=ac=c$ $\implies$ $a=c=0$ (impossible since $ab=b\ne0$) or $a=1,c=\ \text{any value}$. Hence $f(x_1,x_2)=x_1-x_2+c$.
Hence, if $f$ is linear, the only possibilities are $$\boxed{f(x_1,x_2)=c}$$ or $$\boxed{f(x_1,x_2)=x_1}$$ or $$\boxed{f(x_1,x_2)=x_1-x_2+c}$$
Of course if $f$ is not linear there may be other solutions. Since this question is tagged as “linear-transformations” it is presumed that a linear solution is required.