If $M$ is not a group, then there is an element $a \in M$ with no inverse.
Since $M$ is finite, there exists $n>m>0$ with $a^n=a^m$. You can now find a
power of $a$ that is idempotent, and it cannot be the identity, because $a$
has no inverse.
Suppose that $a^m=a^n$ with $n>m$, and hence $a^m = a^{m+(n-m)}$.
We claim that $a^m=a^{m + k(n-m)}$ for all $k \ge 0$, and we prove this by induction on $k$. We have seen that it is true for $k=0,1$. Then, for $k>1$, we have, using the inductive hypothesis for $k-1$, $$a^{m + k(n-m)} = a^{m + (k-1)(n-m) + (n-m)} = a^{m+(k-1)(n-m)}a^{n-m} = a^ma^{n-m} = a^n = a^m$$
as claimed.
Now choose $k$ sufficiently large that $t := m + k(n-m) \ge 2m$. Then, multiplying both sides of $a^m=a^t$ by $a^{t-2m}$, we get $a^{t-m}=a^{2(t-m)}$, so $a^{t-m}$ is idempotent.
For example, if $a^7=a^9$, then $a^7=a^{15}$ and multiplying by $a$ gives $a^8=a^{16}$, so $a^8$ is idempotent.
Ok, so there is a standard argument for this kind of questions (unit of a group is unique; the unit element of a ring is unique etc). The proof is basically the same as below:
For $\forall a \in M$, assume we have two right inverses $b_1$ and $b_2$, then we have $ab_1=ab_2=e$. By hypothesis, we knew there are right inverses for both $b_1$ and $b_2$, say they are $c_1$ and $c_2$ respectively. Then multiply $c_1$ to the equation $ab_1=e$ from right, we have $ab_1c_1=c_1$, then since $b_1c_1=e$, we have $a=c_1$. Similarly, multiplying $c_2$ to the equation $ab_2=e$ from right, we get $a=c_2$. Therefore we showed that $b_1$ and $b_2$ have the same right inverse, namely just $a$. So $b_1a=b_2a=e$. Multiplying $b_1$ to the equation $b_2a=e$ from right, we have $b_2=b_2ab_1=b_1$. Therefore there exists exactly one right inverse.
Actually, this proof gets you a stronger that, this monoid is actually a group.
Best Answer
Let $a$ be an element of a finite monoid.
Then $n>0$ and $k>0$ exist with $a^{n+k}=a^{n}$, leading to $a^{m+kr}=a^{m}$ for $m\geq n$ and $r\geq0$.
Choose some $r$ such that $kr\geq n$ and note that $a^{kr}$ is idempotent.
If identity $e$ is unique as idempotent then $a^{kr}=e$, showing that $a^{kr-1}$ serves as inverse of $a$.