As with any transparent material, lights of different colours travel at different speeds in the material of a prism. Hence, the refractive index of the material of a prism is different for different colours of light. So, when white light enters a prism, its different components (lights of different colours) bend by different amounts which causes the components to split. While emerging from the prism, they undergo a second refraction and bend further, increasing the separation between the colours. In this way, white light gets split into its component colours on passing through a prism.