Waves are created by the vibration of a source. In the case of electromagnetic waves (light) this is the vibration of electrons as they move between energy levels.
In any case the frequency of the wave is dependent upon the nature of the vibrations. Quick vibrations produce high frequency, slower vibrations produce lower frequencies.
Because the frequency is dependant upon what makes the vibration, they are not dependent upon the medium through which they travel. Consequently, as the wave enters a new medium the speed will change. Wave speed, frequency and wavelength are related by
c = LF where c is wave speed, L is wavelength, and F is frequency.
If C changes and F has to remain constant the L must also change. If C goes up, L has to go up, and if C goes down L must go down.