It happens so due to the refraction in glass Slab. The incident ray bends towards the normal as the refracted ray when it enters the glass slab, and bends away from the normal as it comes out of the slab as the emergent ray. Because of the displacement between the incident ray of light and the emergent ray of light. The displacement between emergent and incident ray is called as lateral displacement.
The figure below illustrates the above situation.