We know that the light gets refracted when it enter a medium low/high refractive index.
But why light is not refracted when it comes out from the vertex of a prism.
Light is refracted on the way in and on the way out. The refractive index varies with the wavelength of the light, red being refracted less than blue.
If the "in" and "out" faces of the prism were parallel then the difference in refraction effectively cancels out - look through a window and light directions are not changed. But in a triangular prism the "cancelling " doesn't happen. You can see this if you draw a ray diagram, consult an elementary level book on optics, or just look at the above diagram.