The frequency of light, or any wave, is determined by vibrations of matter. Specifically for light it is the vibrations of electrons between energy levels. Therefore, frequency is set by the matter which creates the wave.
The speed of light depends on the optical density of the material into which it travels, and as light moves from one medium into another the speed changes. The relationship between light speed and frequency is given by the following relationship:
v = f L where v is speed of light, f is frequency, and L is wavelength.
So, if f is set by the matter that creates the wave, and v can change as the light moves from one medium to another, the only way this relationship can be maintained is if the wavelength also changes.