Rainbows ocurr when sunlight travels through droplets of water. The light hits the droplet at an angle and changes direction slightly… due to something called the refractive index… you’ll learn about that in school at some point.
But different colours change direction by different amounts, and so the colours get separated out and we see a rainbow.
Red and yellow and pink and greeeeeeen..Sorry just like the song!! 🙂
It is sunlight that reflects and travels through water. The light changes direction depending on the water droplet it hit and it goes off somewhere else. That other direction means that depending on what angle it went off at, it will produce a different colour.