Whenever you have such abstract looking questions especially in linear algebra, I find it best to look at concrete examples. Say, we have the following matrix-
$$\begin{pmatrix} * & *&0 \\\ * & * &0 \\\ 0 & 0 &1 \\\ \end{pmatrix}\begin{pmatrix}0\\\0\\\x\end{pmatrix}=\begin{pmatrix}0\\\0\\\x\end{pmatrix} $$ So the subspace spanned by $\begin{pmatrix}0\\\0\\\1\end{pmatrix}$ is invariant under this transformation. Now you can why the matrix should be of that form. Just a little hint to put things in perspective.