Fag is a UK word for cigarette
Not sure how it's related to homosexuality or when it 'evolved' to have that meaning.
There are lots of words, some prefer 'Queer'
'fairy' is another one
Poofter, and one I didn't know because people used it like a swear word/expletive that starts with b.
Anyway the rainbow came from Judy Garland's song "Over the Rainbow' and how that came about was because she was liked by gay people. She somehow had an affinity with them, plus her dad, who was one. Her dad died when she was 13 and she had no idea that he was a homosexual but it was a well-known secret that he was, even though he had 3 daughters with his wife.
Anyway her dad who was a theatre guy was run out of town for it, he was preying on young boys.
So what happened was when Judy Garland died, I think it was 1967 or thereabouts, she was only 47 but had lived a life on drugs because of the Wizard of Oz movie (loong story, maybe will tell that one another time, but its out there and you can read about it) she had her funeral in New York and everyone was mourning. She was like America's sweetheart and as well known as Princess Diana in her day.
Some drag queens were mourning/comisserating in a gay bar but at the time that was illegal to be gay (still is in some countries its criminalised, you could go to jail for it) so it had to be secret. The police raided the gay bar but the drag queens pushed back and there was a riot. It was in a place called Stonewall in NYC.
So that was where the movement started, because everyone was playing the 'Over the Rainbow' song when she died, and she used to end it in every concert, sometimes she couldn't even sing it as she'd lost her voice, so the crowd had to sing it to her. The rainbow became a the symbol for the gay movement. I don't know how the 'pride' thing got added but I guess they didn't want to be ashamed of it anymore.