Very simplified: the speed of light isn't constant. The well-known 299.792.458 m/s constant is the speed of light in vacuum - and glass isn't a vacuum. Light goes significantly slower in a lot of mediums, including glass, and it's why things like lenses are possible.