An example of non-closed subspace of a Hilbert space?
Consider the space of square summable sequences and the subspace of sequences whose only finitely many terms are different from zero. This subspace is dense and is not the whole space hence it cannot be closed.
Let $H = L^2([0,1])$ and let $P$ be the set of polynomials in $H$.
It is only possible with infinite dimensions. A good example of a Hilbert space is a set of real or complex sequences for which the sum of squares absolutely converges. The scalar product of two sequences $x=(x_n)$ and $y=(y_n)$ is
$$\sum_{n=0}^{\infty}x_n\overline{y_n}$$
Let's call $x$ finite if there is such $n$ that for each $i>n$ the following holds: $x_i=0$. The subspace of all finite sequences is then not closed. In fact, it is dense.