The light gets refracted when it changes the medium of propagation.The refraction or bending of light towards normal through surface of incidense in denser medium and bending away from the normal to the surface when changing the path from the denser to less denser medium of propagation is the phenomenon. The different coloured light with different frequency bend differently as long as the prism surfaces on which light is incident and emerging are not parallel. But when the surfaces are parallel, the effect of dispersion from the incident surface is undone by the other surface. A glass slab acts in this fashion as it could a join of two prisms which dispersed light from one surface is again undone by the other surface. But the path light in such propagation is laterally shifted.
Let me tell u guy actually it's a false question.. Dispersion of light takes place in both the cases but it's unobservable in case of glass slab as the emerging spectrum can't be differentiated.For proof just use 2 things:
2--the refractive index for violet color is more than red color
it's basically because of the shape the glass slab is rectangular in shape and the dispersion of light takes place when light rays pass a prism at an angle which is not equal to ninty degrees
because after at ninty degrees it will be striking the prism at the angle of the normal and no refraction will take place henceno dispersion of light takes place
I think the reason is the symmetrical shape of the glass slab is responsible for that occurrence.Remember that already dispersed beam can be joined together by keeping another prism inversely,which means two triangle joined to make a rectangular glass block.