Do Matrix Multiplication!
Jelly, 7 5 bytes

Z×þḅ1


Takes B and A as arguments and returns A × B.

Try it online!

How it works

Z×þḅ1  Main link. Left argument: B. Right argument: A

Z      Zip; transpose B's rows and columns.
 ×þ    Table multiplication; multiply all columns of B (rows of B's transpose) by
       all rows of A, element by element. Results are grouped by the rows of A.
   ḅ1  Unbase 1; compute the sum of all flat arrays in the result.