The bending of light rays by a prism is called refraction. An example of this is a rainbow in the sky. The sunlight enters drops of water in the sky and the water drops act like prisms, separating the light into bands of color.
What happens is that when light goes from one material to another it can change speed. Air has a very low density, while glass and water are more dense. The light goes from the air to the light and slows down. Some colors of light slow more than others so you get to see all the colors that are in the light.