Why does the equation $x^2\equiv2 \pmod 5$ have no solutions?

You did: $\,{\rm mod}\ 5\!:\ x\equiv 0,\pm1,\pm2\,\Rightarrow\, x^2\equiv 0,\pm1\not\equiv 2,\,$ a modular brute-force case analysis.

Without brute force: $\,{\rm mod}\ 5\!:\,\ 2\equiv x^2\,\overset{\rm square}\Rightarrow\, 4\equiv x^4\overset{\rm Fermat}\equiv 1,\,$ contradiction.

Remark $ $ The latter generalizes: it is the easy necessary direction of Euler's Criterion, which we summarize below, highlighting the analogy between the simpler additive and multiplicative forms. Note in particular the analogy $\, \color{#c00}n\cdot x\, \leftrightarrow\, x^\color{#c00}n$ between $\color{#c00}n$'th multiples and $\color{#c00}n$'th powers below.

$$\begin{align}&\bmod k\color{#c00}n\!:\qquad\ \ \,\overbrace{\exists\, a\!:\ x \equiv \color{#c00}na}^{\large x\:\!\ \text{an $\color{#c00}n$'th multiple}}\!\!\! \Rightarrow\, kx\equiv 0\ \ {\rm by}\ \ kx \equiv kna \equiv 0\cdot a \equiv 0\\[.2em] &\bmod p\!=\!k\color{#c00}n\!+\!1\!:\, \underbrace{\exists\, a\!:\ x \equiv a^{\large \color{#c00}n}}_{\large x\:\!\ \text{an $\color{#c00}n$'th power}} \Rightarrow\, x^{\large k} \equiv 1\ \ {\rm by}\ \ x^{\large k} \equiv\, a^{\large nk}\! \equiv \underbrace{a^{\large p-1}\! \equiv 1}_{\rm Fermat} \\[.4em] {\rm e.g.}\ \ &\bmod 2\cdot \color{#c00}5\!:\quad\ \ x\,\text{ is a multiple of $\,\color{#c00}5\,$}\,\Rightarrow 2x\equiv 0\\[.2em] &\bmod 2\cdot\color{#c00}5\!+\!1\!:\ x\,\text{ is a $\color{#c00}{\rm fifth}$'th power}\Rightarrow x^2\equiv 1 \end{align}\qquad$$

This analogy will become much clearer if you study the (simple) structure of cyclic groups.


Only half of the non-zero elements of the integers mod $p$, where $p>2$ is prime, can have square roots, because the squaring function $x\mapsto x^2$ is a two-to-one function: $x$ and $-x$ both have the same square.