When light passes through a medium like glass, it can experience a change in its direction and speed. This phenomenon is known as refraction. However, the wavelength of light generally does not change when it passes through glass or any other transparent medium.
The change in direction and speed of light in a medium occurs because the atoms or molecules of the medium interact with the electromagnetic waves of light. These interactions cause the light waves to slow down and change direction. This effect is due to the electric field of the light wave interacting with the charged particles in the medium.
While the speed and direction of light can be altered, the frequency and wavelength remain constant. The frequency of light determines its color, and the wavelength is inversely proportional to the frequency. So, when light passes through glass, it may be bent or refracted, but the energy of the light is not used to shake the atoms or change the wavelength of the light itself.