It doesn't. Light can bend when it encounters a change in the index of refraction, e.g. air to glass or vice-versa. https://en.wikipedia.org/wiki/Refraction#Explanation Light travels in a straight line after it has entered the glass, and again after it exits. Only the angle and the difference in refractive index matters. That's why you can build a Fresnel lens which is, so to speak, all surface. https://en.wikipedia.org/wiki/Fresnel_lens#Description