Show that $S$ is a group if and only if $aS=S=Sa$.
Solution 1:
Here is an outline, see if you can fill in the details.
Pick a specific $a\in S$. Then $a\in aS$, so $a=ae$ for some $e$.
(Aim: this means that $S$ has no possible identity element except $e$, so we have to prove that $e$ actually is an identity.)
For any $x\in S$ we have $x\in Sa$, say $x=ya$. Therefore $$xe=yae=ya=x\ .$$ This proves that $e$ is a right identity, that is, $xe=x$ for all $x\in S$.
See if you can explain for yourself why every element has a right inverse: that is, for all $x$ there exists $y$ such that $xy=e$.
To show that the right inverse is also a left inverse, let $xy=e$ and $yz=e$, then simplify $$yxyz$$ in two ways to show that $yx=e$.
Finally, show that $e$ is also a left identity.
Solution 2:
Let $a \in S$. Since $aaS = S = Saa$, there exist $b, c \in S$ such that $(aa)b = a$ and $c(aa) = a$.
Setting $e = ca$, one gets $e = ca = c(aa)b$ and $c(aa)b = ab$. Therefore $e = ca = ab$ and $ee = (ca)(ab) = c(aa)b = e$. In particular $e$ is idempotent.
Let now $x \in S$. Since $eS = S$, there exist $y, z \in S$ such that $ey = x$ and $ze = x$. Then $ex = eey = ey = x$ and $xe = zee = ze = x$. Thus $S$ is a monoid with identity $e$. Finally, as $xS = S$ and $Sx = S$, there exist $u, v \in S$ such that $xu = e$ and $vx = e$. Thus $S$ is a group.