Question: Prove or disprove: Every commutative binary operation on a set having just $2$ elements is associative. This is from John Fraleigh's 7th edition of A First Course in Abstract Algebra.
![enter image description here](https://i.stack.imgur.com/L8dzk.png)

First of all, how did they realize this is false?

Second, how did they construct this counterexample? How did they know to start with $(a \* a) \* b$ and $a \* (a \* b)$ and know the problem is with these two ? My work here looks too complicated.

The binary operation here is given as commutative, hence $\color{green}{a\*b = b\*a}$.  

For $a \* (a \* b)$, WLOG, suppose $\color{green}{a\*b = b\*a = a}$. Then $a \* \color{green}{(a \* b)} = a\*\color{green}{a}$.

For $(a \* a) \* b$, WLOG, suppose $\color{blue}{a\*a = b}$. Then $\color{blue}{(a\*a)} \* b = \color{blue}{b} \* b$. 

Then $\color{blue}{(a\*a)} \* b \neq a \*\color{green}{(a \* b)} \implies \color{blue}{b} \* b \neq a\*\color{green}{a} $.  

I already picked $\color{blue}{a\*a = b}$ so need $\color{blue}{b} \* b = a$ for a counterexample.

Answer: 
While the example can be constructed easily enough by reasoning of the sort that you used, there is another very straightforward possibility. Since the operation is commutative, we must have $a\*b=b\*a$. There are $2$ independent choices each for $a\*a$, $a\*b$, and $b\*b$, and once these are made, the operation is defined. Thus, there are only $2^3=8$ commutative binary operations on $\{a,b\}$, and it’s possible simply to write them all out and check whether they are associative.
For $(a\cdot b)\cdot a$,let $a\cdot b=b\cdot a=a$,then $(a\cdot b)\cdot a=a\cdot a$
But $a\cdot(b\cdot a)=a\cdot a$.how say associative is false?