In my notation, $\langle\bullet,\bullet\rangle$ is linear in the first variable and anti-linear in the second variable. Let $Q:H\to H$ be defined by
$$ Qh=h-\langle h,e_1\rangle e_1-\langle h,e_2\rangle e_2$$ for all $h\in H$. Note that $Q$ is hermitian because
\begin{align}\langle Qu,v\rangle &=\big\langle u-\langle u,e_1\rangle e_1-\langle u,e_2\rangle e_2,v\big\rangle\\&=\langle u,v\rangle -\langle u,e_1\rangle \langle e_1,v\rangle -\langle u,e_2\rangle \langle e_2,v\rangle\\&=\langle u,v\rangle -\langle u,e_1\rangle \overline{\langle v,e_1\rangle} -\langle u,e_2\rangle \overline{\langle v,e_2\rangle}\\&=\big\langle u,v-\langle v,e_1\rangle e_1-\langle v,e_2\rangle e_2=\langle u,Qv\rangle.\end{align}
Next, we prove that $Q$ is a projection. That is, $Q^2=Q$. To show this, let $h\in H$ be arbitrary. We have
\begin{align} Q^2h&=Q(Qh)=Q\big(h-\langle h,e_1\rangle e_1-\langle h,e_2\rangle e_2\big)\\&=Qh-\langle h,e_1\rangle Qe_1-\langle h,e_2\rangle Qe_2\\&=Qh-\langle h,e_1\rangle \big(e_1-\langle e_1,e_1\rangle e_1-\langle e_1,e_2\rangle e_2\big) -\langle h,e_2\rangle \big(e_2-\langle e_2,e_1\rangle e_1-\langle e_2,e_2\rangle e_2\big) \\&=Qh-\langle h,e_1\rangle (e_1-e_1-0)-\langle h,e_2\rangle (e_2-0-e_2\rangle\\&=Qh-\langle h,e_1\rangle \cdot 0-\langle h,e_2\rangle\cdot 0= Qh.\end{align}
Now, observe that $Qe_k=e_k$ for $k=3,4,5,\ldots$ but $Qe_1=Qe_2=0$. Therefore, for any $h\in H$, $Qh\perp e_1$ and $Qh\perp e_2$. This is because
$$\langle Qh,e_k\rangle =\langle h,Qe_k\rangle =\langle h,0\rangle =0$$
for $k=1,2$, so $Qh\in \{e_1,e_2\}^\perp =E$. This proves that $\operatorname{im}Q\subseteq E$. The final task to show that for any $h\in E$, $Qh=h$, and this establishes the claim that $\operatorname{im} Q=E$. That is, $Q=P_E$. To see this, we suppose that $h\in E$. Thus, $h\perp e_1$ and $h\perp e_2$, so $\langle h,e_1\rangle=\langle h,e_2\rangle=0$. That is,
$$Qh=h-\langle h,e_1\rangle e_1-\langle h,e_2\rangle e_2=h-0e_1-0e_2=h.$$
I think it is generally true that if $\{e_1,e_2,e_3,\ldots\}$ is an orthonormal basis of a separable Hilbert space $H$ and $P$ is the orthogonal projection onto a closure of the subspace spanned by $\{e_k:k\in A\}$, where $A$ is a subset of $\Bbb N_1$, then $$Ph=\sum_{k\in A}\langle h,e_k\rangle e_k=h-\sum_{k\in \Bbb N_1\setminus A} \langle h,e_k\rangle e_k$$
for all $h\in H$. In other words, $P$ is the projection onto the orthogonal complement of $\{e_k:k\in\Bbb{N}_1\setminus A\}$.
Best Answer
Let $x\in X$. We have $P_n(x)=\sum_{j=1}^n\langle x,e_j\rangle e_j$ so , by Bessel-Parseval equality $$\lVert P_nx-x\rVert^2=\sum_{j\geq n+1}|\langle x,e_j\rangle|^2.$$ As the latest series is convergent we have the result.
Now, let $K\subset H$ compact. Fix $\varepsilon >0$. Then we can find an integer $N$ and $x_1,\dots,x_N\in K$ such that for each $x\in K$, we can find $1\leq k \leq N$ such that $\lVert x-x_k\rVert\leq\varepsilon$. Fix $x\in K$. Then $$\lVert P_nx-x\rVert^2=\sum_{j\geq n+1}|\langle x-x_k+x_k,e_j\rangle|^2\leq \varepsilon^2+\max_{1\leq k\leq N}\sum_{j\geq n+1}|\langle x_k,e_j\rangle|^2.$$ As the RHS doesn't depend on $x$, we have $$\sup_{x\in K}\lVert P_nx-x\rVert^2\leq \varepsilon^2+\max_{1\leq k\leq N}\sum_{j\geq n+1}|\langle x_k,e_j\rangle|^2.$$ Now take the $\limsup_{n\to+\infty}$ to get the result.
Note that the property of approximation of a compact operator by a finite rank operator is true in any Hilbert space, not only in separable ones. To see that, fix $\varepsilon>0$; then take $v_1,\dots,v_N$ such that $T(B(0,1))\subset \bigcup_{j=1}^NB(y_j,\varepsilon)$. Let $P$ the projection over the vector space generated by $\{y_1,\dots,y_N\}$ (it's a closed subspace). Consider $PT$: it's a finite ranked operator. Now take $x\in B(0,1)$. Then pick $j$ such that $\lVert Tx-y_j\rVert\leq\varepsilon$. We also have, as $\lVert P\rVert\leq 1$, that $\lVert PTx-Py_j\rVert\leq \varepsilon$. As $Py_j=y_j$, we get $\lVert PTx-Tx\rVert\leq 2\varepsilon$.