Note $$\left(\frac{a^2}{5}\right)$$ is the Legendre symbol.
I used wolfram alpha to see if, $$\left(\frac{a^2}{5}\right) = 1$$ and this is true for integers from $1$ to $10$ and it is except $5$ and $10$, which are divisible by $5$. So is this true in general for any $a$ not divisible by 5?
The expression $$\left(\frac{a^2}{5}\right)$$ asks if there exists a natural number $x$ such that $$x^2\equiv a^2 \bmod 5,$$ from the definition of the Legendre Symbol. You simply let $x=a$ to satisfy the equation, so such an $x$ does exist, that is why Wolfram-Alpha returned a $1$ for this Legendre Symbol.
When $5 \mid x$, it is clear that $5 \mid a^2$, so the Legendre gives $0$ by definition.