I find it strange that a region that finds homosexual and transgender acts to be normal and protected by multiple gods dedicated to homosexuality has this king who banned the practice and both parties involved would face the death penalty.
Since male prostitutes and homosexuality was the domain of multiple well known gods, this is stranger since you'd would think they would respect the gods of their own pantheon.
Even stranger, Nezahualcoyotl was a philosopher who pushed the finality of life and how all humans are flawed. It seems insane that a philosopher would do this, even with the implication that he doubted the dominant religion of the time by certain people.
Are there any known reasons why Nezahualcoyotl put some harsh punishments on this act and how did religious sects react to a king ordering the death of followers of multiple gay gods of their own pantheon? What made him go against the grain in seemingly every way he could, even in context to the region he lived in?
I can't fully answer your question, but I can give some extra context on a few points that I believe satisfies Askhistorian's requirements, as well as link you to some prior posts by flaired users touching on some elements of this that will hopefully be helpful.
Most of what we know about Nezahualcoyotl comes from accounts written by descendants of Texcoca royalty within the first century or so of Spanish rule in Mexico, most notably by Fernando de Alva Cortés Ixtlilxóchitl. In his works, Nezahualcoyotl is glorified as exceptional leader: A codifier of laws and legal reformer; a poet and patron of the arts; a key spearheader of the Aztec triple alliance and diplomat and general during the war against Azcapotzalco which gave rise to the Aztec Empire, and a engineer who designed a variety of waterworks systems like the dike which bore his name, the redesign of Tenochtitlan's Chapultepec aqueduct, the watering systems of the royal gardens at Texcotzinco; etc.
One of the things which is claimed of him in these accounts, beyond what I mentioned, is he was a religious skeptic, apparently rejecting human sacrifice and Aztec polytheism and instead worshiped a monotheistic god. If this is starting to sound awfully convenient, then therein is the problem: As with all sources, Ixtlilxóchitl has a bias in his writings, being to glorify his own lineage and heritage, especially in the context of the contemporary Spanish administration. While not all the claims about him are likely to be false, there is enough evidence to call into question the claim of rejecting human sacrifice (other documents name him participating in plenty of ceremonies with the practice) and the degree of involvement he had in the war against Azcapotzalco. Some of the poetry ascribed to him also may have not been written by him, as his status as a renowned poet meant that many poems without known authors were simply said to be written by him. Also, while not relating to Nezahualcoyotl, Ixtlilxóchitl also claims that the Mexica of Tenochtitlan sacrificed 1 in 5 children, which is a obviously insane claim which shows the sort of pro Texcoca, anti Tenochca perspective he was writing from.
I don't know exactly which source lists Nezahualcoyotl as outlawing homosexuality and sodomy, personally, but if it was by Ixtlilxóchitl, then a very plausable explanation is that in the context of the then current Spanish administration, where those acts were viewed with intense disdain, claiming Ixtlilxóchitl outlawed those things would have been a way for Ixtlilxóchitl to make the Texcoca dyansty look better.
It's important to note though that, to my knowledge most sources on Aztec religion and nontraditional gender roles written at the time, regardless of city, describe it as something either dimmly viewed or outright punishable via execution. this series of comments by /u/400-rabbits delves into this more (in fact the second comment on the chain talks about Texcoca revisionism of Nezahualcoyotl), but it's hard to tell how much of these sources is accurately describing cultural rejection and disdain for what we'd call homosexuality, transgender or non-binary identities, etc, or if this is merely how the Spanish were viewing and filtering Mesoamerican sexuality and gender concepts which originally had validity in (at least certain) prehispanic contexts. While widespread acceptance of third gender roles which may include identities we'd view as homosexual may have been the case, that's merely one interpretation, it's possible that it still wasn't that well viewed or was only accepted in specific social or ritualistic contexts, etc.
I'm not really equipped to comment on what the academic consensus is on the exact roles and claims you bring up, I'll leave that to 400-rabbits and others, but hopefully my comment at least gives some extra context.
A big thanks to /u/jabberkwockxeno for linking to the past answer I gave on Nahua homosexuality, and for tackling the current question. I just want to expand upon what they have already written by questioning some of the assumptions built into your question. This is not calling you out, just illuminating how murky the topic of homosexuality can be in Mesoamerica, and among the Aztecs in particular.
Gay Gods
Your question posits that homosexuality and transgenderism were “normal” and had dedicated deities. Were they and did they though? To start with the notion of patron gods of homosexuality and specifically male prostitutes, the deity Xochipilli is often cited as filling that role in the Nahua pantheon, but there really is no evidence of him actually being the protector of those classes of people. Doing a little detective work on the source of this idea of course led me to Wikipedia, which cites Greenberg (1990), "Construction of Homosexuality," as saying
One of the Aztec gods, Xochipilli, was the patron of male homosexuality and male prostitutes; he may have been taken over from the earlier Toltec civilization, which had a reputation for sodomy among both the Mayas (whom the Toltecs conquered), and the Aztecs (who conquered the Toltecs). (p. 165)
The way this is worded immediately sets off a number of red flags for me. First, anyone claiming specifics about Toltec deities needs to be appraised skeptically. Outside of archaeological evidence, virtually every source on the Toltecs is filtered through what later Nahuas wrote about them, often holding up them up as paragons of both culture and warfare, and using them to justify their own claims of legitimacy. I’m sure there are some sources out there which might draw upon flower and nobility imagery to make an argument for a iconographic Toltec precursor to the Aztec Xochipilli, but drawing a direct line is much more tenuous.
Equally tenuous is the geopolitical summary given by Greenberg. The notion that there was an overwhelmingly powerful and widespread Toltec Empire which conquered much of Mesoamerica is now seen as an outdated view based upon taking the mythologizing of the Toltecs by the Aztecs far too literally and uncritically. The notion of a singular Mayan Empire is likewise a long-debunked notion.
What this seems to be referring to is the supposed conquest of Chichen Itza by “Toltecs” in the early Postclassic. While there are similarities in architectural and iconographic styles between what is found at Tula and Chichen Itza, the notion that the latter was conquered directly by the former is now discounted in favor of theories of indirect influence, local power struggles, and “mexicanized” Maya. All of this is getting far afield from the question at hand though, but if you’re interested in this topic check out Twin Tollans: Chichén Itzá, Tula, and the Epiclassic to Early Postclassic Mesoamerican World.
Anyways, the sources Greenberg gives for these claims are Eric Thompson’s (1966) The Rise and Fall of the Maya Civilization and a 1987 dissertation from Taylor, El Ambiente: Male Homosexual Life in Mexico City. The former has nothing to do with the Aztecs or latter is actually a study of contemporary gay life, though placed within historical context. It is from Taylor, however, that we get the phrasing used by Greenberg, as the dissertation states that Xochiquetzal “in her male aspect, Xochipilli, she was worshipped as deity of male homosexuality and male prostitution” (p. 12). Taylor does not cite anything for this claim. He does, however, write that
It has been suggested that ritual homosexuality and other forms of ritual eroticism were introduced into Yucatan during the Mexican Toltec incursion and that such practices were contrary to Maya concepts of ritual purity. (p. 12)
As already noted, the concept of a “Mexican Toltec incursion” into the Yucatan is disputed, to say the least. Taylor at least gives a citation for this claim… Thompson’s The Rise and Fall of the Maya Civilization. Thompson, based on my limited access to this text, does not say anything about homosexuality, let alone actually mentioning Xochipilli. Instead he writes that “the Maya were particularly shocked by erotic practices introduced by the Itza, apparently as part of the cult of Quetzalcoatl-Kukulcan” (p. 108). The Itza, in this arrangement, are a term for the supposed Toltec invaders.
To bolster this claim, Thompson cites a passage from the Chilam Balam, which says:
Their hearts are submerged [in sin]. Their hearts are dead in their carnal sins. They are frequent backsliders, the principal ones who spread [sin], Nacxit Xuchit [synonym for Quetzalcoatl] in the carnal sin of his companions, the two-day rulers. [They sit] crookedly on their thrones; crookedly in carnal sin. Two-day men they call them. For two days [endure] their seats, their cups, their hats. They are the unrestrained lewd ones of the day, the unrestrained lewd ones of the night, the rogues of the world. (Roys, 1933, p. 97) The problem here is that this passage is presented as the words of a prophet/holy man who is condemning the introduction of depravity and deprivation brought by foreigners... because they are failing to embrace Christianity. Large parts of the Chilam Balam are thought to have been written during the invasion of the Maya region by the Spanish and the Aztec allies, so the quoted passage does not necessarily refer to a Toltec incursion. Another passage in the Chilam Balam actually echoes this language, while making it explicitly clear that the context was the Spanish conquest of the Yucatan (p. 33). Also, note that homosexuality is not mentioned at all, just generally admonitions against carnality and lewdness.
Every claim I could find that Xochipilli oversaw the domain of male homosexuality stems eventually came back to Taylor and Thompson. The foundation on which Xochipilli is erected as the patron god of gay Nahuas is an uncited throwaway line in a dissertation that was actually focused on 20th century gay life in Mexico city, with allusions to a mid-century text on the Maya, which itself did not discuss homosexuality at all. The claim has no basis.
Likewise claims of other deities who might represent a sort of patron to homosexual and/or genderqueer Nahuas are also dubious. Tlazolteotl often gets brought up as a goddess with masculine elements, but even Sigal (2011) who can find phallic symbolism in a depiction of the goddess in the midst of giving birth only goes so far as to conclude that the Tlazolteotl deity complex is one which melds both masculine and feminine aspects, but does not necessarily represent a patron deity of homosexuality.
Sigal sees Tezcatlipoca as a counterpart to Tlazolteotl, and another deity with depictions which sometimes incorporate female markers. Again though, Sigal does not see Tezcatlipoca as a “god of homosexuality,” instead placing the deity in the context of religious worship rich with symbols of sacrifice, fertility, and sensuality. Keep in mind that this is a scholar who states that the flute blown by the ixiptla of Tezcatlipoca during Toxcatl represents fellating the god, and that the ixiptla breaking his flutes symbolically transforms him into a feminine vessel to be “penetrated” by the god through the act of sacrifice. Sigal is not one to go for half-measures; if he thought there was an Aztec God of Gayness, he would highlight in rainbows and spell it out using phallic letters.
Even Titlacahuan, an aspect of Tezcatlipoca, is dismissed by Sigal as having a direct connection to homosexual Nahua men. Recall from my other post that there are a couple passages in the Florentine Codex where Titlacahuan is cursed as a “cuiloni,” the passive or receptive partner in a male homosexual dyad (stronger terms are often used in the translation). Kimball (1993) sees this as evidence that “there was some kind of relationship between homosexual men and the trickster persona of the god Tezcatlipoca, named Titlacahuan.”