Matrix A has 1 row, and 4 columns. Matrix B has 3 rows, and 4 columns
In order for A*B to be possible, A has to have the same number as columns as B has rows. In other words, the inner dimensions have to match up. The '4' in '1x4' needs to match up with the '3' in the '3x4'. This match doesn't happen.
The same story happens with B*A, just things have been flipped.
B has 3 rows, 4 columns A has 1 row, 4 columns
The "4 columns" of B does not match with "1 row" of A.