Here are the details of Jonas's suggestion. Let $X$ be self-adjoint with dense domain $D(X)$, and let $M$ be a closed subspace with $M\subseteq D(X)$ and $X(M)\subseteq M$. Let $P$ be the orthogonal projection onto $M$. Then $D(PX) = D(X)$ while $D(XP)=H$ as $P$ has range $M\subseteq D(X)$. For $\xi\in H$, let $\xi_0=P(\xi), \xi_1=\xi-P(\xi)$, and let $\eta\in D(X)$. Then $ (PX\eta|\xi) = (PX\eta|\xi_0) + (PX\eta|\xi_1) = (PX\eta|\xi_0) = (X\eta|P\xi_0) = (X\eta|\xi_0) $ as $PX\eta\in M$ and $\xi_1\in M^\perp$. As $\xi_0\in M\subseteq D(X)$ and $X$ is self-adjoint, $ (X\eta|\xi_0) = (\eta|X\xi_0) = (\eta|PX\xi_0) = (P\eta|X\xi_0) = (XP\eta|\xi_0), $ as $X\xi_0 \in X(M) \subseteq M$. Similarly, $(XP\eta|\xi_1) = 0$ as $XP\eta \in X(M) \subseteq M$ and $\xi_1\in M^\perp$. As $\xi$ was arbitrary, this shows that $XP\eta=PX\eta$. So we've shown that $ D(PX) \subseteq D(XP), PX\eta=XP\eta \ (\eta\in D(X)) \implies PX \subseteq XP. $
As the OP claimed, this is enough. If $e$ is an eigenvector of $X$ then $PXe = P\lambda e = \lambda Pe$, and by the above, this also is equal to $XPe$. So $Pe\in M$ is an eigenvector for $X$ (unless it's zero!) As the original collection of eigenvectors has desne linear span, so does the projection onto $M$.