The light ray incident on a glass at A comes from the opposite at B. Inside the glass slab, the seven constituent colors travel the same distance and emerge through B.
Whereas in the case of Prism, the distance travelled by different colors are diffrrent because of the prism shape (of the order of few wavelength).