A semigroup of cardinality $2$ has no identity 
To prove a semigroup of cardinality $2$ has no identity, let  $(X,\cdot)$ be that semigroup with $|X|=2$ such that $x,y\in X$ and $x\neq y$. Now let/s assume $x$ is the left identity. Therefore
  $$y=x\cdot y=x$$
  ...

Why does $x\cdot y=x$ if we assumed that $x$ is left identity? I saw this in a lecture. I saw now that before the lecturer wrote that for all $|X|\geq 2$, $y\in X$ must be a right inverse, so from there he found out that $y=x\cdot y = x$.
 A: The statement in question is false.
By definition, a left identity is an element $e$ satisfying $ea=a$ for all $a$. Indeed, if $e\not=a$ this means $ea\not=e$, so in your example $xy\not=x$. I suspect your lecturer was instead proving that if a semigroup has a left identity and a right identity, then they are the same: if we let $x$ and $y$ be a left and right identity, respectively, then $x=xy$ since $y$ is a right identity, and $xy=y$ since $x$ is a left identity, so $x=y$.
Incidentally, I think you may separately be interested in seeing a few semigroups with two elements! (If nothing else, this should de-mystify things a bit so that you see why the statement in the question is bogus.) Remember that a semigroup is just a set with an associative binary operation; anything else (identity, inverses, commutativity, . . .) is an unnecessary bonus. 


*

*The nicest kind of semigroup is a group; so the nicest two-element semigroup is the two-element group. In addition to being a group, this semigroup is also commutative, since the only group of order $2$ is commutative. In general, there will be many semigroups of a given size that are also groups, but for prime sizes, there's only the one, and it's commutative (or, abelian).

*Next up we have semigroups with identity, but which aren't groups. There's only one of these up to isomorphism of order $2$: namely, the one defined by $1\cdot 1=1, 0\cdot 1=1\cdot 0=0\cdot 0=0$. Here $1$ is a left and right identity, and $0$ is a left and right annihilator. Again, this one is commutative; I call it "source/sink" (I don't know if it has an actual name).

*It might seem like these are the only two; but there's more! We also have the projections - the ones where the semigroup operation is just projection onto either the first or second coordinate. That is, the left projection semigroup is described by $$0\cdot 0=0\cdot 1=0,\quad 1\cdot 0=1\cdot 1=1;$$ that is, $x\cdot y=x$. Similarly, the right projection semigroup is given by $x\cdot y=y$. These semigroups are counterexamples to lots of reasonable guesses - for example, every element in the left projection semigroup is a right identity, and no element is a left identity; and dually for the right projection semigroup.
It's a good exercise to show that these are all the two-element semigroups that there are: the 2-element group, the "source/sink" semigroup, and the left and right projection semigroups. (EDIT: I missed one, thanks Joshua Tilley.)
There's an interesting subtlety to the projections: although these two semigroups are basically the same idea, they're not isomorphic! The one is the opposite semigroup of the other. It can be confusing at first to realize that the opposite structure isn't isomorphic to the original structure. 
Advanced digression: For another context where we consider opposite structures, look at rings; one of my favorite theorems in algebra is that the "opposite map" $A\mapsto A^{op}$ is the inverse operation in a particular group, whose elements are themselves algebraic structures (namely, division rings)!

Less relevant, but still good context:
At the same time, it's worth pointing out that there are natural binary operations which aren't associative, and hence don't form a semigroup. On two elements, we have the Sheffer stroke, or NAND, operation; it satisfes $$0\cdot 0=0\cdot 1=1\cdot 0=1,\quad 1\cdot1=0.$$ It is non-associative, since it satisfies $0(11)=00=1$ but $(01)1=11=0$. While not being associative, it is commutative, and in fact has a cancellation property making it a quasigroup; it does not, however, have an identity, so it is not a loop. Note that any commutative loop with two elements is either the two-element group, or the source/sink semigroup.
Incredibly irrelevant, but hopefully fun:
It's also worth pointing out that there are lots of interesting weak versions of associativity:


*

*Alternativity: $(x\cdot x)\cdot y=x\cdot (x\cdot y)$ and $y\cdot (x\cdot x)=(y\cdot x)\cdot x$ for all $x, y$.

*Power associativity: I can put parentheses however I want in expressions involving only one element; so e.g. $x\cdot (x\cdot (x\cdot x))=(x\cdot x)\cdot (x\cdot x)$.
Power associativity is strictly weaker than alternativity. In particular, there are lots of algebraic structures which are not quite semigroups, but are better than magmas. 
Incidentally, these versions of associativity are actually naturally-occurring: you've probably heard of the complex numbers, and you might have heard of their weird cousins the quaternions. Well, the quaternions have their own weird cousins, the octonions, and similarly to the octonions we have the sedenions. (We can keep going, too.) Each move - from reals to complexes to quaternions to . . .  - is performed in the same way, so this is really a meaningful series of structures, not just some random things we're pulling out of a hat.
The interesting thing is, multiplication in these structures gets progressively worse and worse. The quaternions aren't commutative anymore; the octonions aren't associative, but they are alternative; and the sedenions are power associative but not alternative. So a hierarchy of associativity principles grows out of trying to understand this sequence of algebraic structures.

Aaaand I've gone way beyond the bounds of the original question, so I'll stop there. But hopefully the first bit clarified what's going on, and gave some useful examples; and hopefully the second bit was fun. 
