If you apply the same gate twice on a state $|\psi\rangle$ you will get out the state $|\psi\rangle$ if the hermitian of the gate is the same as the gate. In your case, you applied the Hadamard gate, $H$, twice on (presumably) the $|0\rangle$ state, and so you got $|0\rangle$ as your result.

This happens because it is a requirement for quantum computing that gates be unitary. A unitary matrix $U$ is defined as a matrix where $$UU^\dagger = I$$ where $I$ is of course the identity matrix. Let's do $H^\dagger$ real quick: that requires doing the transpose of the matrix (i.e., flipping the elements across the diagonal), and then the complex conjugate of each of the elements. There's no complex numbers in the matrix, so we don't need to worry about that - and doing the transpose just means flipping $1$ and $1$. So $H^\dagger = H$.

So when you apply $H$ twice to your state, you are effectively doing $HH$ - and it is a requirement that this come out to $I$. $I$ is literally defined as a matrix where $$XI=X$$So here's what you are doing: $$HH|\psi\rangle $$ and we know that $HH = I$, so you are doing $$I|\psi\rangle $$ and we know that any thing multiplied by $I$ gives itself so you just get out $$|\psi\rangle$$

Hopefully this answers your question.

Wouldn't this depend on the initial state? – Norbert Schuch – 2019-08-18T17:49:21.787