Why does frequancy stay the same when going through different mediums?

Because the frequency at any point along the wave propagation direction has to be the same as the frequency of the device that produced the vibration.