$\mathbb{Z}_p^*$ is a cyclic group of order $p-1$, so by Lagrange theorem if $a^{\frac{p-1}{2}} = y$ we have $$y^2 = (a^{\frac{p-1}{2}})^2 = a^{p-1} = 1$$ So y is a root of $x^2 -1 \in \mathbb{Z}_p[x]$, but $\mathbb{Z}_p$ is a field and so there are at most $2$ roots, i.e. $\lbrace 1, -1\rbrace$.
So $y = a^{\frac{p-1}{2}} = \pm 1 $.
Moreover if you define $$\phi : \mathbb{Z}_p^* \to \lbrace 1, -1 \rbrace$$ $$\gamma \to \gamma^{\frac{p-1}{2}}$$ this is a surjective ( because $p-1 > \frac{p-1}{2}$ ) homorphism group, and so the cardinality of the kernel, call it K, is $\frac{|\mathbb{Z}_p^*|}{2} = \frac{p-1}{2}$.
The squares $\mod p \ $ in $\mathbb{Z}_p^*$ are $\frac{p-1}{2}$, because if $\alpha, \beta \in \mathbb{Z}_p^* $ and $\alpha^2 = \beta^2$ this implies $\alpha = \pm \beta$.
So we have that $$H = \lbrace \alpha^2 \mid \alpha \in \mathbb{Z}_p^* \rbrace \subseteq K$$ and $|H| = |K|$. This means that $H = K$ and so for $a \in \mathbb{Z}_p^*$ $$ a^{\frac{p-1}{2}} = 1 \Leftrightarrow a \ \text{is a square}$$