When light enters from one medium to another,
it deviates from its path and this phenomenon is called refraction of light.
Atmosphere is composed of layers of optical densities and due to the variation
in air density there is the deviation of light or other electromagnetic wave
from a straight line when it passes through the atmosphere known as
Atmospheric refraction.
Because of Atmospheric refraction, the light rays travel a curved path as shown in the figure. During sunrise, light rays bend and reach eyes earlier than actual line of sun and during sunset, light rays bend and the sun is visible for a longer time than that if the sun-rays were straight lines.
Hence, the Sun is visible to us about 2 minutes before the actual sunrise, and about 2 minutes after the actual sunset. Actual sunrise, mean the actual crossing of the horizon by the Sun. The time difference between actual sunset and the apparent sunset is approx. 2 minutes.
The apparent flattening of the Sun's disc at sunrise and sunset is also because of Atmospheric refraction.