Light is either a wave or a particle. It is considered to be energy, since it has no mass when it behaves like a wave. It is not an object, just energy traveling. A photon has an initial energy. When it is traveling in vacuum, it has no obstacles, nothing to go through. So with its initial energy, it can travel at high speed. When it is traveling through air, there are some molecules that it has to go through. When it is going through a molecule, it has to spend more energy than vacuum because it is going through a molecule. When it is water, there are more molecules to go through but their formation isn't as tight as solid, so it is a little slower than air, but faster than solid. When it is traveling through a solid, there are a lot of molecules to go through that are tightly together, so it takes more and more energy to pass them. Photons still have the same energy, but they are spending more energy to go through molecules, so they use 70% of the energy to speed in glass, when they can use 100% in vacuum.
Here is an analogy: You are driving on a highway. The road is very good, no holes, no bumps so you can go very fast. When you are going through a neighborhood, there are speed bumps, so you have to slow down every time. You are spending more effort to go through them, you have to apply the brakes, then put the pedal on the metal again. When there is no road, you are going very slowly, because there are holes on the road, stones that you go over and so on. But in every case, it is the same driver, same car. Everything is the same except the road.
Light can gain its speed back, because it is not an object. It has the same energy, traveling in whatsoever material. But it has to use more and more energy to go in glass, then in air. So when it gets to air again, it has the same energy, it speeds up.