So, for the given element a, you know that there is an element e such that ae=a, and there is an element f such that fa=a. Now let b be another element of S. There is an element y such that ya=b. Therefore be=yae=ya=b, and by a similar argument fb=b. This shows that e acts as a right identity for every element of S, and f acts as a left identity for every element of S. Therefore in particular e=fe=f. Hence e is an identity.
Suppose that S contains n elements (n is finite). Given an element a in S, think about the set of products ax as x runs through S. There are n of these products and (by the cancellation property) they are all distinct. So they must constitute all the elements of S. Therefore, given an element b of S, one of those products ax must be equal to b. In other words, the equation ax=b has a solution. Similarly, the equation ya=b has a solution. So now we can use the result from problem 1 to conclude that S is a group.