$$\operatorname{ord}_n(a) = \min\{ k \ge 1 : a^k \equiv 1 \pmod{n} \}, \qquad a^m \equiv 1 \iff \operatorname{ord}_n(a) \mid m$$
The order of $a$ mod $n$ is how long it takes powers of $a$ to cycle back to $1$, and any exponent giving $1$ must be a multiple of that order.