Rescattering effects on kaon energy spectra in heavy-ion collisions