It is because of atmospheric refraction. When the Sun is slightly below the horizon, the light coming from it travels from less dense to more dense air and is refracted downwards. Thus, the Sun appears to be raised and can be seen 2 min before actual sunrise and 2 min after actual sunset.