As The Photon says, it's because of boundary conditions.
To elaborate on his/her answer: when an EM wave propagating through vacuum enters into a dielectric material occupying a different region of physical space, the boundary between the two regions is a timelike hypersurface (since its normal vector is spacelike). Therefore the "time-conjugate" part of the wave four-vector - the frequency - must stay the same in order for the EM fields to remain continuous across the boundary.
If instead you had a spacelike hypersurface boundary between the vacuum and the dielectric regions - e.g. you had an EM wave propagating through a vacuum and then all of space suddenly became filled with a dielectric - then the wavelength would stay the same and the frequency would change, because the "space-conjugate" part of the wave four-vector - the spatial wave vector - would need to stay the same in order for the EM fields to remain continuous across the boundary.