Matrix multiplication is defined as:
Let $A$ be a $n \times m$ matrix and $B$ a $m\times p$ matrix, the product $AB$ is defined as a matrix of size $n\times p$ such that $(AB)_i,_j = \sum\limits_{k=1}^mA_i,_kB_k,_j$.
For what good reason did mathematicians define it like this?
A matrix is nothing but a particular representation of a linear map (with respect to a choice of basis in source and target space). The formula is what results (naturally) if you look at the composition of such maps and write them down using a matrix.