When I was a kid it was a common trope that the traditional rainbow had 7 colours because Christians thought 7 was a Godly number, and 6 was an evil number. So they split the last colour into 2 (indigo and violet). Atheists would use this to ridicule religious people for doing irrational things. In hindsight maybe there's more to this than mere superstition.
@GMOdysseys it bugs me that when discussing this they use spectrum and colour wheel interchangeably. When they are 2 very different things. The colour wheel just adds purple in there to blend the 2 ends together.
@ned numerology has some merit, but it's unscientific and it's not like it has divinatory power. It's more like numbers have symbolic meanings in different cultures, and so the invocation of those numbers in different contexts adds richness to what you're seeing or reading. The fact that you noticed that the rainbow used to have seven hues and the gay pride flag has six is a perfect example of this. It's a form of subtext.