Because they're not? (the same size, that is).
A(i) is an element of A, B is an array or vector.
You need an addressing expression on the left that's the same size as
size(B)
to assign to an array unless you make it a cell array by encapsulating B in the curly braces "{}"