Why associativity $h \circ (g \circ f) = (h \circ g) \circ f$ is required in composition?

An introduction into category theory says that

A category is a quadruple $A = (O, \mathrm{hom}, \mathrm{id}, \circ)$ consisting of blah-blah and is subject to the following conditions: (a) composition is associative: $$h \circ (g \circ f) = (h \circ g) \circ f,$$ ...

What is the point of this requirement? If I get the parenthesis right, $(h \circ g)$ says that we first submit some $x$ to the rightmost $g$. This function will convert $x$ to some $y$, which will then be submitted to function $h$. It automatically follows that parenthesis play no role: the computation propagating from right to left as if there are no parenthesis. They are transparent by default. Why to stipulate the thing, which is inevitable?


$\phantom{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}$

Counterexample 1:

enter image description here

Counterexample 2:

Take the "category" with one object, one arrow for each octonion, and multiplication of octonions for composition. This (like Counterexample 1) satisfies all the axioms except associativity.


As the comments state, morphisms do not act on elements; they are abstract arrows with abstract composition rules. If you don't require associativity, you could have scary one-object categories modelled on algebraic structures such as loops or even magmada (with identity), which makes things much harder to deal with, as dropping associativity makes arbitrary composition difficult (once again stated in the comments).


Consider the "category" which has four objects $x_1$, $x_2$, $x_3$, $x_4$, in which

  • $\hom(x_i,x_i)$ has exactly one element for each $i\in\{1,2,3,4\}$, the identity of $x_i$;

  • $\hom(x_i,x_j)$ is empty if $i>j$;

  • $\hom(x_1,x_2)=\{\alpha\}$, $\hom(x_2,x_3)=\{\beta\}$, $\hom(x_3,x_4)=\{\gamma\}$, $\hom(x_1,x_3)=\{\delta\}$, $\hom(x_2,x_4)=\{\eta\}$ and $\hom(x_1,x_4)=\{\xi,\zeta\}$;

  • composition is defined so that the identites act as identities, $\beta\circ\alpha=\delta$, $\gamma\circ\beta=\eta$, $\eta\circ\alpha=\xi$ and $\gamma\circ\delta=\zeta$.

You can easily check that composition in this "category" is not associative.