I'm going to focus on Rome as I am much more well read on that area as opposed to the Greeks. The big issue and the hardest one to wrap modern heads around is that the ancients did not have the same ideas on sexual orientation that we do today.
They did not identify people as being homosexual or heterosexual or anything of that sort.
There was nothing incongruous about a man having sex with another man (one woman and another woman however is a whole different issue that I am not particularly familiar with any research on) and still being "normal".
For them the most important part of sex was who was doing the penetrating in the sex rather than the sex of the receiving party. The Romans certainly believed penetration to be a masculine endeavor and being penetrated a feminine one.
Furthermore these "relationships" (whether they indicate genuine romantic attachment or just sexual desire, power fantasies, and so on is anyone's guess and would have course been highly variable) were almost exclusively master/slave relationships and not carried out between two free Romans.
There was also the matter of discretion. Flaunting your sexual conquests of slaves and other low class people of the same sex would likely not have been particularly acceptable in polite company, much better to just be kept in house so to speak. Emperors who were...less cautionary....with such acts often faced censure and criticism for them, though how legitimate these accusations were is another matter of debate.
In short, the Romans were not super concerned with gay sex between men and their slaves so long as it was the free man who was carrying out the penetration in sex, anything else would have been extremely humiliating.
Sources:
Eva Cantarella. Bisexuality in the Ancient World
Catharine Edwards. The Politics of Immorality in Ancient Rome
Craig Williams. Roman Homosexuality: Ideologies of Masculinity in Classical Antiquity
For Classical Greek society (or actually I should say Athenian, as most if not all sources center on Athenian practice and culture), a lot of what was said above is also valid.
The free male Athenians of higher class furthermore engaged in a sort of idealized pederastic relationships, involving a mature and educated man and a younger man who was his pupil (the age difference is important; a homoerotic relationship between two mature men would probably have been considered more aberrant). This is always a one-on-one situation: don't imagine school teachers engaging in this, rather think of 'personal mentor'-like situations.
This is a prominent idea in e.g. the philosophies of Socrates, it features for instance in Plato's Symposion. Homoerotic sex was considered a normal part of such an interaction, and was surrounded with al sorts of romantic ideals - probably significantly more so than the marital life between man and woman. The latter was important for procreation, but as women led mostly secluded lives, it played little part in (Classical) Greek public life. Homoerotic sex of this kind was also not considered adulterous.
Here, too, it is important that the mature, wise man is always the penetrator and his pupil is always the penetratee. I don't think the practice on the whole was considered much of a taboo (whereas we would be shocked considering young the age that some pupils involved would have), although it may have invited raucous jokes at parties (like the Symposion), and it is made fun of in Aristophanes (though I have to say I cannot point out specific passages at this point).