Since the rod is brought near B, it becomes momentarily polarized, so the electrons in B move to A and it becomes net negative, and B is net positive. But since protons can’t move from sphere to sphere(only electrons) A also becomes polarized on its own, and all electrons are on the left and all protons on the right, since the protons are also attracted to the negative rod. Therefore, since unlike charges repel, A moves away from B.