Explanation:
Any light when it passes through a medium of different density will change its direction. As the light passes through a material of different density the speed of light changes which causes the light to bend.
White light is the mixture of all the colors of the visible electromagnetic spectrum. When it passes through a prism each wavelength of the visible spectrum gets bent. This causes the white light to split into the rainbow which we see.