he probably was constrained somewhat in his behavior by the military structure and ethos. In the military services, as in any other organization of humans, people who want to get ahead figure out how to work within the organization's system and use its structures and operations to their advantage. As long as Flynn was a member of the Army he behaved himself according to the Army's rules because he knew that's how he could get ahead, and as an officer he was very successful. Obama appointed him as DIA in 2012, and in that capacity he was the primary military intelligence advisor to the Secretary of Defense - which meant that for the first time he had to work under a civilian hierarchy. As DIA he was said to be a chaotic and difficult manager who regularly disagreed with other leaders of the intelligence community and who took extreme and Islamophobic positions on how to deal with terrorism, and he was finally forced out of that job in 2014.
It is very likely that his underlying assholishness finally bubbled to the surface due to being fired from the DIA job, and what he did afterwards was motivated at least in part by bitterness and revenge.
It's a classic Russian intelligence move to recruit or suborn people who are some combination of bitter, narcissistic and/or greedy. Flynn seems to be all of those things.