In a category associativity is the condition that the two ways to use binary composition of morphisms to compose a sequence of three morphisms are equal
If the category has a single object it is a monoid and this condition is the associativity condition on the binary operation of monoids such as groups, rings, algebras, etc.
More generally, in higher category theory, associativity of composition of morphisms in an n-category means that the different ways to use binary composition for composing collections of k-morphisms form a contractible infinity-groupoid. This is a coherence law.
For instance the associativity law in an A-infinity algebra is the special case of associativity in a 1-object A-infinity-category.
See associahedron.
In a monoidal category associativity is the statement that the associator satisfies its coherence law, which is true by a coherence theorem.
The coherence law of associativity is stated in