When a sound wave passes from one medium into another, its frequency stays the same. The frequency is set by the source, and the number of waves arriving at the boundary each second must equal the number leaving it. The speed of the wave changes, so the wavelength must change too, because wave speed = frequency × wavelength.
Sound travels faster in a solid than in a liquid, and faster in a liquid than in a gas. This is because the particles are closer together, so a vibration is passed on more quickly. In air sound travels at about 340 m/s, and in water at about 1500 m/s.
Take a 500 Hz sound moving from air into water. In air the wavelength is 340 ÷ 500 = 0.68 m. In water the speed increases and the frequency is the same, so the wavelength increases and is longer: 1500 ÷ 500 = 3 m. If the sound moves into a medium where it is slower, the wavelength gets shorter.