ANSWER and EXPLANATION
The reason why the sun is visible before it rises and after it sets is the atmospheric refraction that occurs.
When the sun is just below the earth's horizon, the rays of light coming from it suffer atmospheric refraction from a rarer to a denser medium in the earth's atmosphere. So, they tend towards the normal at each refraction.
Due to this refraction, the sun may be seen for several minutes before it rises and after it sets.