The socially accepted norm and idea that homosexuality or any other sexuality that did not involve heterosexuality was a dominant mentality that stayed for generations and ironically, there were some eras in history where homosexuality or LGBT sexuality was not really treated with contempt and disgust like in ancient Greece.
Despite the recent yet slow change and awareness of this mentality and slow acceptance of LGBTQIA rights among many people around the world (and not just by people who were already familiar that being gay and not-hetero was not a deviant behaviour), homophobia still exists in some regard and even held strongly in some countries.
My question is how this mentality originated and how this has been shared and supported generally for many generations and also among many different cultures regardless of their religions/beliefs, nationalities, philosophies and so on
This is a super broad question and there isn't actually a single answer that stretches across time and covers everything. You should read some of the answers in the FAQ on gender and sexuality but these ones in particular might be interesting:
How common was homosexuality (or what we'd now see as homosexuality) in Ancient Greece? and Did the ancient Egyptians share the Greeks' views on sex and sexuality? by /u/cleopatra_philopater
What was it like being gay in ancient Rome? How socially acceptable was it? by /u/thebatteryhuman and /u/MarsTheGodOfWar
I can only ping three users a pop so I'm continuing this below