Let $a$ be an integer such that $0 \le a \le 7$ and $a^2 \equiv a \pmod{8}$. If $a \neq 0,$ then find the value of $a$.