If matrix X has m columns and n rows and matrix Y has p columns and q rows, in order to be able to multiply XY, we must have that m= q and then XY has p columns and n rows.

If A has n columns and k rows then has k columns and n rows. In order to be able to multiply , must have n columns and, since it is invertible it is square, n rows. That means that has k columns and n rows. And then is the product of a matrix with n columns and k rows by a matrix with k columns and n rows. k= k and the product is a square matrix withnrows and columns.