This phenomenon of mirages is due to total internal reflection of light rays from air layers having different densities.
During hot summers, the air layers are very hot near the road or hot sand in a desert. So their density is lower than the air layers on top of them. Since the densities are different, the optical density or refractive indices also become different.
When light rays from a distant object fall on the interface between these layers, light travels from higher density medium (layer) to lower density one. For the rays with angle of incidence more than that of the critical angle, the total internal reflection occurs.
when we see the image of the distant object as coming from underneath the road or sand , we feel that there is some water on the horizontal surface in place of hot sand or hot road.
so we feel the mirage.
when the air layers are continuously changing speeds due to air convection, and breeze, the refractive indices of the layers continuously change. So we see the images like we see images in a flowing water or the surface of with some waves.