[step:Verify that every projection $P_M$ is self-adjoint and idempotent]
Conversely, let $M\subset H$ be a closed linear subspace and assume
\begin{align*}
P=P_M.
\end{align*}
For each $x\in H$, the definition of $P_M$ gives the orthogonal decomposition
\begin{align*}
x=P_Mx+(x-P_Mx),
\end{align*}
where
\begin{align*}
P_Mx\in M
\end{align*}
and
\begin{align*}
x-P_Mx\in M^\perp.
\end{align*}
Since $P_Mx\in M$, applying $P_M$ again leaves it fixed:
\begin{align*}
P_M(P_Mx)=P_Mx.
\end{align*}
Thus
\begin{align*}
P_M^2=P_M.
\end{align*}
To prove self-adjointness, let $x,y\in H$. Define
\begin{align*}
m_x:=P_Mx,\qquad n_x:=x-P_Mx,\qquad m_y:=P_My,\qquad n_y:=y-P_My.
\end{align*}
Then $m_x,m_y\in M$ and $n_x,n_y\in M^\perp$. Since $M$ is orthogonal to $M^\perp$,
\begin{align*}
(P_Mx,y)_H=(m_x,m_y+n_y)_H=(m_x,m_y)_H
\end{align*}
and
\begin{align*}
(x,P_My)_H=(m_x+n_x,m_y)_H=(m_x,m_y)_H.
\end{align*}
Therefore
\begin{align*}
(P_Mx,y)_H=(x,P_My)_H
\end{align*}
for all $x,y\in H$. Hence $P_M$ is an orthogonal projection operator, and so $P=P_M$ is an orthogonal projection operator.
[/step]