In TDK, Batman is used as a third party agent by Gordon and Dent, to among other things, kidnap the Gotham mafia's accountant after he flees to a country with no extradition treaty with the US to avoid arrest. It's also shown that Bruce is dabbling into serious illegal surveillance technology which he ultimately gives to Lucius Fox for safekeeping.
Also, the inciting event that leads to the mafia setting into motion the event that causes Harvey being disfigured and becoming Two Face, is Harvey deciding to use RICO laws and push them to their absolute extreme: pretty much if you were a member of the Gotham Mafia in any shape or form in any way, you were snatched off the street and charged under RICO and forced to stay in jail with no bail. And you were told you either snitch on anyone and everyone you knew and get a reduced sentence or you are basically going away to jail for life even if you were a lowly goon. This ultimately causes the hit to be placed on Harvey and his girlfriend Rachel, with the people carrying out their kidnapping and the placing of the bomb that kills Rachel and disfigured Dent being done by crooked cops (who already hate Dent for being ex IAD) on the mob's payroll who are TERRIFIED of being busted as part of Dent's RICO scheme. And in the end
Dent's RICO scheme is VERY controversial and everyone, save Batman, tell him that he's just asking for a bleeding heart liberal judge to kick him in the balls and dismiss all the charges with prejudice/declare RICO investigations illegal. As well as the fact that it will invite intense scrutiny from defense attorneys and critics, who will look for anything and everything in Harvey's life to try and find a way to discredit him or force him to resign in disgrace in order to stop the RICO prosecutions. So when Harvey goes insane and starts killing people and tries to kill Gordon's kids? Gordon and Batman unilaterally decide to let Batman take the fall for all the murders Harvey did and Batman killing Dent (when he dies fighting Batman) so Dent's successors can continue the RICO indictments and Dent can be made into a saintly martyr and the police's ties with a vigilante publicly severed.
Cut to ten years later and Dark Knight Rises. Dent's death leads to draconian new tough on crime laws being passed by the state government where Gotham is located. Most notably, a law called "Harvey Dent's Law" which straight up abolished bail for ALL CRIMES. Meaning if you got arrested for ANYTHING, no matter how minor, you are fucked and have to rot in jail until trial or you plead guilty and do prison time, as Gotham was now a police state with massive prison overcrowding due to prosecutors going tough on crime to the extreme. The mafia is all but wiped out but Gordon by the start of DKR, regrets everything he has done and even writes out a confession he chickens out on reading during a ceremony celebration on Gotham being a police state dystopia.
Adding to this, is the fact that while crime is down, quality of life is still garbage in Gotham. The rich get richer and the poor get poorer and worse, the elite seem to be immune to being targeted by the new anti crime laws while the white working class live in constant fear of being vanished if they so much as jaywalk. And Nolan's Batman doesn't give a shit about the poor; instead of using the Wayne Foundation to address the severe economic disparity to keep the poor white population from having to turn to crime to survive, he spends the ten year time skip crying about how Rachel was dead and how he was convinced that she was going to dump Dent for him (which Alfred finally has to break down and admit was not true and that he burnt Rachel's final letter to Bryce saying she was going to marry Harvey because Bruce being Batman was a deal breaker).
In the end, Bane recruited his army from people who got fucked over by the police state, people like Catwoman who are accelerationists who want to burn everything to the ground and who basically expose Dent's crimes and Gordon and Batman being in cahoots but can only do so by mass killing people and holding Gotham hostage via a nuclear bomb, cutting Gotham off from the rest of the country and turning it into an even worse hell, as the criminals are all freed to do as they please, while the police are all trapped in the sewers.