Both sides mean f(g(h(x))). With the identity function I(x)=x, f∘I=I∘f=f on the appropriate domain.
Example
For f(x)=x+1 and g(x)=x2, (f∘g)(x)=x2+1, while (g∘f)(x)=(x+1)2. At x=1, the outputs are 2 and 4. Thus associativity does not imply commutativity. An inverse is special: composing it with the original function returns the identity on the corresponding set.
Avoid this mistake
Canceling f from f(a)=f(b) requires injectivity. It is not a general algebraic cancellation rule.