Matrix multiplication is not commutative; however, when finding the inverse of a matrix, the order matters as it involves multiplying the original matrix by another matrix to achieve the identity matrix. We have left inverse and right inverse and they are not always the same for a given matrix.
Note that’s only for the case where the matrices are not square. In that case, they have to be different because the dimensions don’t even work in the other order. Those are usually called “pseudo-inverses”. When mathematicians say matrix inverses, they only mean for square matrices.
In the case of square matrices, the left and right inverses are the same. Here’s a proof:
Suppose A and B are square matrices and A \cdot B = I.
B \cdot (A \cdot B) = B \cdot I = B
Matrix multiply is associative, so we have:
(B \cdot A) \cdot B = B
We know that det(A \cdot B) = det(A) * det(B) = 1, so det(B) \neq 0 and thus B is non-singular and invertible.
((B \cdot A) \cdot B) \cdot B^{-1} = B \cdot B^{-1} = I
(B \cdot A) \cdot (B \cdot B^{-1})= I
B \cdot A = I
So B = A^{-1} and we’ve shown that:
A \cdot B = B \cdot A = I
Of course it is true that matrix multiplication is not commutative in general, but that doesn’t mean that there aren’t special cases in which it can be.