Since nobody mentioned Euler theorem here is another answer.
If $\gcd(a,30)=1$ then $a^{\varphi(30)} \equiv 1 \pmod{30}$ and $\varphi(30)=8$. Or $30 \mid a^8-1$ and $a^{25}-a=a(a^{24}-1)=a(a^8-1)(a^{16}+a^8+1)$. Thus $30 \mid a\cdot(a^{24}-1)$
If $\gcd(a,30)=d \in \{2,3,5,6,10,15,30\}$ then
- $d=30$ then $30 \mid a \Rightarrow 30 \mid a\cdot (a^{24}-1)$
- in all the other cases $30=d\cdot d_1$, $d \mid a$ and $\gcd(d_1,a)=1$ then $$a^{\varphi(d_1)} \equiv 1 \pmod{d_1} \tag{1}$$ or $30=d\cdot d_1 \mid a\cdot (a^{\varphi(d_1)}-1)$. But $d_1 \in \{2,3,5,6,10,15\}$ as well and $\varphi(2)=1,\varphi(3)=2,\varphi(5)=4, \varphi(6)=2, \varphi(10)=4, \varphi(15)=8$ all are factors of $24$. Or $24=\varphi(d_1)\cdot q$ and from $(1)$ $$a^{24}\equiv a^{\varphi(d_1)\cdot q} \equiv 1^{q} \equiv 1 \pmod{d_1}$$ Thus $30=d\cdot d_1 \mid a\cdot (a^{24}-1)$ too.