Suppose we want to multiply a matrix A by a matrix B. To do so, the number of columns in A must equal the number of rows in B. If this is not the case, the multiplication is not defined.
The resulting size is: (number of rows in A) x (number of columns in B).
For example, if A is m x n and B is n x p, the product AB is m x p. The visualization below (from CueMath) may be helpful.