Does associativity imply commutativity?

I used to think that commutativity and associativity are two distinct properties. But recently, I started thinking of something which has troubled this idea:
Here using associativity of addition operation, we’ve shown commutativity.

In general,
For any natural $a,b$.
Hence using only associativity we prove commutativity. That this can be done, is disturbing me too much. Is this really correct? If yes, then are associativity and commutativity closely related? Or is it because of some other property of natural numbers? If yes, then can it be done for other structures as well?

Well done – you’ve essentially rediscovered free objects. In particular, what you’ve observed is that in the semigroup freely generated by one element (call it $1$), addition happens to be commutative.

In other words: you’ve essentially explained why addition in $\mathbb{Z}_{\geq 1}$ is commutative.

But, I wouldn’t say that associativity implies commutativity in general. For instance, multiplication of $2 \times 2$ matrices provides a fundamental example of an associative operation that isn’t commutative. Furthermore, the non-equivalence of associativity and commutativity is clear even if we stick to free algebras:

• in the semigroup freely generated by two elements (call them $A$ and $B$), commutativity fails in a big way. For example, $A + B \neq B+A$ in this context.

• in the commutative magma freely generated by one element (call it $1$), associativity fails in a big way. For example $(1+1)+(1+1) \neq ((1+1)+1)+1$ in this context.

Free algebras are pretty tricky, so don’t feel discouraged if you don’t ‘get’ them right away – nobody ever does. It can take a year or two before the idea truly ‘sinks in,’ and almost discovering them yourself will only help a little in this regard.

You may find this question helpful to get you started.