This is one of those cases where you can vectorize the code, but doing so will be hard to read and likely less efficient than a loop.
The vectorized version of your code is, for R2016b or later:
A((B-1).*size(A,1)+(1:size(A,1)).')
For R2016a or earlier,
A(bsxfun(@plus, (B-1).*size(A,1), (1:size(A,1)).'))
You can see that this involves creating multiple temporary matrices the size of your index, and several mathematical calculations that have no obvious meaning.
For small arrays, this is clearly premature optimization: a case where something that might maybe faster but more complicated has been substituted for something clear, when the code was never going to occupy much computation time anyhow, and the human costs of reading and debugging the code are going to far out-weigh any computation time saved.
For larger arrays... well, this can actually turn out to take more time than using a loop, because of the large temporary arrays needed.