That happens because of refraction.
At the boundary between two different media, each color bends a tiny tiny tiny tiny amount different from how the other colors bend, so they come out of the other side all spread out.
5.6m questions
7.3m answers