When a ray of light travels from one transparent medium to another, its speed changes, causing the ray to change its direction. This phenomenon is called refraction of light.
Consider a light ray travelling through air → water → glass → air.

1. Air to Water
When light enters water from air, it travels from a rarer medium to a denser medium. Therefore, the ray bends towards the normal.
2. Water to Glass
When the ray travels from water to glass, it again enters a denser medium because the refractive index of glass is greater than that of water. Hence, the ray bends towards the normal again.
3. Glass to Air
Finally, when the ray emerges from glass into air, it travels from a denser medium to a rarer medium. Therefore, it bends away from the normal.
Important Result
If the first and last surfaces are parallel, the final emergent ray is parallel to the original incident ray, although it is shifted sideways. This sideways shift is called lateral displacement.
Remember for JEE/NEET:
Rarer → Denser → Towards normal
Denser → Rarer → Away from normal
The amount of bending depends on the refractive indices of the media and the angle at which light strikes the surface.