How would you find the linear transformation that takes each (x,y) point and projects onto the line y=x?
How do you want points to travel to the line y = x? I could easily think of a way to do this using rotation matrices. But then a point would not travel to the closest point on y = x from its original location. It would travel to the nearest point on y = x that is on the circle with radius equal to its own distance from the origin. In other words, they would travel around on a circle until they reached y = x. But if you use the term "projection", I think you mean that each point goes straight towards the nearest point on y = x, right?
I would interpret "projection" as meaning "orthogonal projection". That is, to project $\displaystyle (x_0, y_0)$ onto the line y= x, draw the line throught $\displaystyle (x_0, y_0)$ perpendicular to the line y= x. The projection is at the intersection of those two lines.
Of course, any line perpendicular to y= x is of the form y= -x+ A. Taking $\displaystyle y= y_0$, $\displaystyle x= x_0$, We have $\displaystyle y_0= -x_0+ A$ so that $\displaystyle A= x_0+ y+0$. The line perpendicular to y= x is $\displaystyle y= -x+ x_0+ y_0$. That intersects the line y= x when $\displaystyle x= -x+ x_0+ y_0$ or $\displaystyle 2x= x_0+ y_0$ so that $\displaystyle x= \frac{x_0+ y_0}{2}$.
The point $\displaystyle (x_0, y_0)$ is projected onto the line y= x at the point $\displaystyle \left(\frac{x_0+ y_0}{2},\frac{x_0+ y_0}{2}\right)$.
That is $\displaystyle L((x_0, y_0))= \left(\frac{x_0+ y_0}{2}, \frac{x_0+ y_0}{2}\right)$
You could also write this as the matrix multiplication
$\displaystyle \begin{bmatrix}\frac{1}{2} & \frac{1}{2} \\ \frac{1}{2} & \frac{1}{2}\end{bmatrix}\begin{bmatrix}x_0 \\ y_0\end{bmatrix}$