I'd lie to start by saying I know very little about 20th century historu as I'm usually more interested in the Middle Ages so if I make a mistake it's not intentional.
From what I've read it appears that for the time period Hitler held a fairly liberal position on homosexuality which allowed Rohm to rise high within the party. He even appeared to stand by him when he was attacked for having an openly homosexual friend. As for as I'm aware there was also other openly homosexual men within the SA.
Yet after the Nazi's came to power they tried to 'cure' homosexuals and those who couldn't be cured were sent to the camps. Was it the increasing influence of Himmler and the SS which forced Hitler to persecute homosexuals, the focus on perfect family structure or did his own views change?
The move of Hitler from an apparent acceptance of men like Ernst Röhm to sanctioning a very harsh state repression of gays seems at first glance to be incongruous. But there really is not that much of a mystery to this apparent reversal. The long and the short of it is that Hitler's views on homosexuality was not really that liberal to begin with and predisposed him to accept a harsher line.
Hitler, like many of fellow German politicians, had precious little to say about male homosexuality. Outside of a few exceptions, most Weimar public figures took a hard line against open homosexuality and associated homosexuality with deviance and unmasculine behavior. This was a line not uncommon within the whole German political spectrum. The left-wing SPD and KPD parties backed the repeal of Paragraph 175, but some of their leaders were reluctant to be seen as champions of this type of sexual freedom. The KPD's deputies often framed their opposition to Paragraph 175 as being on the side of science and rationality versus religious superstition. The NSDAP for its part did not see Paragraph 175 as a path towards electoral victory. Socially conservative issues like the decriminalization of homosexuality had less of a place within the NSDAP's strategy than attacks on Versailles, unemployment, and the Republic's inability to master the Depression.
But the NSDAP was far from a safe party for homosexuals. When Goebbels first learned of Röhm's homosexuality, he wrote in his diary "we can't have this, the Party as the el Dorado of the 175ers!" Röhm fit in with his colleagues only with a degree of friction. Röhm tended to be more candid about his proclivities in private NSDAP and other social circles, although he also tried to compartmentalize his personal life away from his political one. The SA leader cultivated a very hypermasculine image both in his own life and his leadership of the SA. According to Röhm, masculinity was the highest form of power and discipline. He valorized the camaraderie of the frontline trenches and male community. Röhm's Weltanschauung associated chaos and disorder with feminine characteristics. His ideal world was one in which women had little to no say and male virtues reigned supreme in society. His attacks on Paragraph 175 obliquely as a public figure were notable, but he was no Magnus Hirschfeld; Röhm's views on sex almost exclusively focused on male pleasure. Lesbianism or even straight female sexuality had little space in SA visions of an ideal society. He in private maintained that his sexual proclivities were just an expression of this masculinity. But gay liberation was not his main focus. Rather, Röhm framed male same-sex sexuality as a component of a social order that was highly patriarchal and very heteronormative when it came to defining masculinity. The ideal men in Röhm's view were to be militaristic and men of action. There was little room for alternative masculinities such as crossdressing in this narrow definition of gender.
Röhm benefited from the fact that NSDAP could not afford to be too picky when it came to its leaders. The party may have pole-vaulted into a mass party in the 1930s, but its internal coalition was quite fractious. In the case of Röhm, Hitler did not really want to alienate a leader of the NSDAP's political wind and was content to keep the SA chief's sexual matters quiet. Things came to a head when the SPD-affiliated Münchener Post published a series of reports in 1931 and 32 about Röhm's sexuality and the presence of other homosexuals within the SA and NSDAP. This was when Hitler weighed in that Röhm's private dalliances were no cause for his dismissal.
Conservative commentators in the postwar FRG as well as twenty-first century US have taken Hitler's support for Röhm in this period at face-value to charge that the NSDAP was pro-homosexual. This is not only mistaken, but it also misses the point. Hitler's support for Röhm was tactical in nature; it kept the party from potentially fraying while attempting to defang the Post's expose of a scandal. The Post-Röhm affair did not lead to any change in party policy or fundamental alterations on its approach to sexual issues.
But a tactical approach to homosexuality swung both ways. The SA's regimented, violent, and predatory masculinity had made Röhm an asset to the NSDAP in its seizure of power. But Röhm's ideas on social leveling via mass paramilitarism made him powerful enemies within the Reichswehr. Additionally, the SS also recognized that Röhm was a rival, as did Göring. This constellation of enemies meant that Röhm's star fell precipitously after the seizure of power. His homosexual activities became a liability in this internal power struggle. But they were just a pretext for the extrajudicial murder of the SA's leadership during the Night of the Long Knives. It was a convenient excuse that the SA leadership was filled with degenerates justified what were politically-motivated executions.
The dictatorship beefed up Paragraph 175 and turned male homosexual sexual contact into a felony. Hitler, as far as he involved himself in these sexual matters, sanctioned this new approach. But he was more interested in issues of foreign policy and rearmament than moral issues. Himmler was not and took a special interest in rooting out homosexuality from the new regime and the SS. But even here, this idée fixe of Himmler had a tactical element to it in that it gave the SS another arrow in its quiver to attack potential rivals within the polycratic Nazi state. The Gestapo used evidence of an alleged homosexual affair to bring down Werner von Fritsch, the chief of the German military. Hitler could have repeated his approach in the Post affair and insist this was a personal matter and all that mattered was Fritsch was a good soldier. But he did not. By the same token, he did not intervene against the crackdowns against homosexuals in the 1930s and 40s. His sole major intervention in favor of Röhm (and by extension, homosexual rights) was done in the name of political expediency. It was a performance he did not repeat.
Sources
Hancock, Eleanor. Ernst Röhm: Hitler's SA Chief of Staff. Basingstoke: Palgrave Macmillan, 2012.
Marhoefer, Laurie. Sex and the Weimar Republic: German Homosexual Emancipation and the Rise of the Nazis. Toronto: University of Toronto Press, 2015.
Siemens, Daniel. Stormtroopers: A New History of Hitler's Brownshirts. New Haven: Yale University Press, 2017.