Technically a rainbow can form anytime there are water droplets in the air, and sunlight to shine through them. Pragmatically, there’s a better chance of the sunlight getting the right angle in the earlier morning and late afternoon. Since most summer rainstorms happen in the afternoon, most rainbows probably get formed in the afternoon, too.
If the field of droplets is thick enough, a vantage point may get more than one rainbow.
So there’s a good deal of chance in this photo. A good photographer is ready, when the chance presents itself.
Did you notice the colors are reversed in the secondary rainbow?