Nothing is wrong with the math. In matrix multiplication the inner dimensions go away. Please also see