Let $g$ be a generator of the multiplicative group, and let $a=g^s$. We are trying to find a number $e$ between $1$ and $p-1$ such that $(g^e)^n=g^s$.
So we want $g^{en}\equiv g^s\pmod{p}$. This holds if and only if $en\equiv s\pmod{p-1}$.
Now consider the congruence $en\equiv s\pmod{p-1}$, where $e$ should ne considered variable. This congruence has a solution if and only if $\gcd(n,p-1)$ divides $s$.
We therefore want to show that $\gcd(n,p-1)$ divides $s$ if and only if
the order of $a$ divides $\frac{p-1}{\gcd(n,p-1)}$.
We will do one direction in detail, and leave the other direction to you. We show that if $\gcd(n,p-1)$ divides $s$, then the order of $a$ divides $\frac{p-1}{\gcd(n,p-1)}$.
It is enough to show that $a$ raised to the power $\frac{p-1}{\gcd(n,p-1)}$ is congruent to $1$ modulo $p$. So we want to show that $g^s$ raised to the power $\frac{p-1}{\gcd(n,p-1)}$ is congruent to $1$ modulo $p$. To do this we need to show that $s\cdot \frac{p-1}{\gcd(n,p-1)}$ is a multiple of $p-1$.
This is obvious. For we are told that $\gcd(n,p-1)$ divides $s$, say $s=a'\gcd(n,p-1)$. Then
$$s\cdot \frac{p-1}{\gcd(n,p-1)}=s'\gcd(n,p-1)\cdot \frac{p-1}{\gcd(n,p-1)}=s'(p-1),$$
and $s'(p-1)$ is a multiple of $p-1$.