You correctly identify function composition and relation composition as associative operations, and then appear to ask this question:
Since all the operations that we call composition are already proven to be associative, why do we make associativity a requirement of composition operations?
There are two subtle bugs in this question.
- You assume that the collection of operations that we call composition only contains function and relation composition. But this is not so: I think I could, given time, write down 20-30 different classes of composition operations, with each class containing an infinite number of actual composition operations!
- Your assumed causal relation is backwards. We do not start by calling a bunch of different things composition, and then deciding to demand that they be associative; rather, first we identify some conditions that we like (associativity, having an identity, being well-typed) and then allow ourselves to attach the label "composition" to any operation that fulfills those conditions.
Let's do some examples, in the style of point (2). We will first build up a mathematical structure of interest to us, then we will ask: can we call this a category if we want to?
Sets with function composition
Suppose I proposed the following mathematical structure:
- There is a big collection of objects, one for each set that's possible. (This statement can't be formulated in set theory! But that's okay. We don't have to work in set theory if we don't want to.)
- There is a collection of arrows for each pair of objects; namely, for sets X and Y, there is one arrow of type X -> Y for each function whose domain is X and whose codomain is Y.
- To compose two arrows, we use standard function composition from set theory.
Is this structure a category? As you correctly observed in your question, the answer is yes, because:
- For any object X, we can create an arrow of type X -> X for which composing with other arrows does nothing (namely, the function that returns its input unchanged).
- As you correctly observed, we can prove that function composition is associative.
Numbers with addition
Here is a somewhat simpler structure:
- There is a single object, named X.
- There is a collection of arrows of type X -> X; in this collection is one arrow for each natural number.
- To compose the arrows representing numbers m and n, produce the arrow representing the number m+n.
Notice that in this structure, the composition operation we have defined is neither function composition nor relation composition! The question we are asking now is: are we lying to ourselves when we attach the label composition to this operation, or is that a sensible thing to call it?
In this case, the answer is yes, we can call it composition (and call the whole structure a category), because:
- We can create an arrow of type X -> X for which composing with other arrows does nothing (namely, the arrow representing the number 0).
- As we all know, addition is associative.
Positive numbers with addition
How about this slight modification to the previous example:
- There is a single object, named X.
- There is a collection of arrows of type X -> X; in this collection is one arrow for each positive natural number.
- To compose the arrows representing numbers m and n, produce the arrow representing the number m+n.
Can I call this a category? Is this relation something to which I can attach the label "composition"? (Note that the operation itself is the same operation as before!) In this case, the answer is no, we should not call this structure a category, and we should not call this operation a composition, because although the operation is associative, there is no arrow which leaves other arrows unchanged when composing with them.
Numbers with weird exponentiation
One more structure:
- There is a single object, named X.
- There is a collection of arrows of type X -> X; in this collection is one arrow for each natural number.
- To compose arrows m and n:
- If either of m or n is 0, return the other. For example, the composition of 0 and 1 is 1; the composition of 2 and 0 is 2; and the composition of 0 and 0 is 0.
- Otherwise, take the exponentiation m^n.
Can we call this structure a category? Is the final operation something we could label as a "composition"? In this case, the answer is no, because although there is an arrow which leaves the others alone under composition (namely 0), the purported composition operation is not associative:
2^(1^2) = 2^1 = 2
(2^1)^2 = 2^2 = 4
With some work, we can cook up fancier examples that fail the category laws in even subtler ways (for example, by being associative, but only having one-sided identities). But by now I hope the pattern is clear: the category laws are desiderata that we use, and the decision we make in each case is about whether a mathematical structure we are interested in is something we can call a "category". (Of course, we are still allowed to be interested in it and study it even if the answer to that question is no!)