Why does wavelength of a light change when it passes from one medium to another?
Light changes wavelength as it passes from one medium to another because it changes speed as it enters the new medium.
Light’s energy is defined as its frequency multiplied by the Planck constant ( ##E=hf##). When light travels from one medium to another, its energy doesn’t change, so its frequency stays the same, this is observed as light not changing color as it passes through glass. However, its speed does change (kind of). From the formula ##v=flambda##, the velocity changes so the wavelength changes.
As light travels from a less dense medium to a more dense medium (like from air to glass), its velocity decreases, so the wavelength increases. It is this change that causes light to bend. This is determined from the materials refractive index, using the formula ##v_2/v_1=n_1/n_2##.
Now the speed of light doesn’t actually change, because the speed of light is a fundamental constant. However, it does take longer to pass through a medium with a higher refractive index. For this explanation, we can think of light as a particle. Refractive index is determined by a material’s density. When light passes through a material of high density (glass for instance), it collides with and is scattered from the glass molecules. So the light doesn’t actually take a straight path through the material, it bumps from molecule to molecule. In a dense material, there are more particles in a smaller volume so it gets bumped around more, and ends up taking a longer distance to the other end of the medium as compared to a less dense material. But the speed of the light from molecule to molecule is always c, but we like to simplify it to say that it travels in the shortest distance, but at a different speed.