The rainbow is only showing when light is put trough a prism or another object that can reflect, refract, and disperse the light source. Typically this object is rain drops when you see rainbows out in the "wild" / non-laboratory setting.
It's important to keep in mind that it's not just the 7 colors that are reflected in the rainbow - the entire color spectrum is shown. We as humans are limited to only see the seven main colors, but animals that has a wider color spectrum sensors can actually see more colors in each end of the rainbow. One end goes into the infrared colors, while the other end goes to the UV colors.
The rainbow also shows all the gradients between each of the seven main colors, but these can be difficult to see for yourself without a way to zoom into the rainbow.
There is a lot more to tell about rainbows, but it quickly delves into the world of particle physics, and I'm not comfortable going any further. We got some great physicists here on the Steem blockchain, so one of them might be able to give a better explanation than I did.