Governments are big, and different parts want different things.
The military has use for Tor. Intelligence agencies and law enforcement have the same and similar uses.
In fact the underlying system was originally developed by the navy, for the navy.
If you read the recently leaked NSA documents regarding Tor, specifically this one it becomes apparent that they don't have any backdoors into the system (or at least didn't when those documents were created) as most of the attacks are either known or go after separate software such as Firefox.
While development attacks are a real threat the open-source nature of Tor helps defend against them. There's also the fact that there are many white-hat researchers constantly doing their best to find any holes in Tor so it may be better secured.
Also, unless they were NSA from the get-go I seriously doubt any of the developers would turn to the dark side. You don't give away countless hours of your time for free unless you care about what you're doing; they could just as easily have gotten a six figure job invading people's privacy instead.