If $a^{n}\equiv 1 \pmod m$, then $aa^{n-1}\equiv 1 \pmod m$, so $a^{n-1}$ is the multiplicative inverse of $a$ modulo $m$ and $\gcd(a,m)=1$.
What I don't understand is why $\gcd(a,m)=1$ and $a^{n}\equiv 1 \pmod m$ imply that exists an $n$ such as $n<m$ ?
Thanks
Consider all different positive powers of $a$ modulo $m$. In other words, the sequence $$ a, a^2, a^3,\ldots\pmod m $$ It will necessarily be a repeating sequence, and as there are at most $m-1$ possible values a term could take, we must be back at $a$ again at the latest with $a^m$. The one before that (at latest $a^{m-1}$) must be $1$.