As a bi male I've wrestled with this idea for years as well OP. Here is where I currently stand on my own theories and ideas. This is only my opinion and I would really love to see data backing any of this up or disproving it, but for now this is what I go with.
The first thing we need to understand is that male homosexuality is more than just a misfire or anomaly, the fact that the prostate is positioned in just the right location to feel pleasure from having another dick penetrate your ass is reason enough to disprove that, as coincidences in evolution are often not coincidences, but the result of providing a biological advantage to passing on your genes in some way. Beyond that, one can look at r/K selection theory and simple ideas when it comes to breeding strategies that can help explain this. This is by no means a simple issue to tackle, as it has multiple facets to it. As such, I have been able to divide up types of homosexuality into different camps for different reasons. These ideas are by no means conclusive, nor mutually exclusive to each other.
The first, and seemingly well accepted idea from some studies I have found is the idea of a male submitting to another male as a way to show he is not a threat to him. This allows that submissive male to infiltrate the other males collection of women, thus allowing him a chance to breed and having the other male raise his young. You see this with femboys and the like. This is sort of a r-select way to infiltrating a K-select's group, as the submissive male is not likely to share his resources with his offspring and in fact will leech resources for himself. This strategy is very similar to sneaky male strategies seen in other species.
This way, however, does not explain the other ways male homosexuality exhibits itself. The current majority of homosexuality, as seen via CDC studies, is the very promiscuous kind that sleeps with men in a series of one night stands, and only seeks pleasure, is a very r-select style. It follows very closely with the normal r-select mentality that the quality of the offspring is not important, only the quantity is, and thus it could be seen as a misfire for basic r-selects who only seek pleasure and the ability to breed as often as possible with as many partners as possible. Essentially, a hole is a hole, just keep fucking.
This still does not explain the warrior cultures of ancient times. Many of those cultures had men who would, for lack of a better term, pair bond with each other while at the same time having a wife of their own to breed with. For this I have to look at the way the human brain makes these kinds of pair bonds, and the answer is our old friend dopamine. Sexual pleasure is one of the highest releases of dopamine into our system, thus we get addicted (or fall in love with) the action that got us that hit. When our number of partners is low, we make that association with the partner, when it is high we associate it with the act. A pair of males who bond together like this, but who also have wives, will be more likely to opt to share resources and protect each other, even going so far as to help raise each others offspring, thus increasing both males odds of passing on their genes. I see this form as a very K-select idea, and often is the style I see many conservative homosexuals practice.