The government isn't one thing. It might be worth doing some reading on systems thinking, for instance some of the writing by Donella Meadows. People inhabit a government system and they either set boundaries for themselves, or have those boundaries asserted onto them; boundaries between their area of influence and other areas of the system they consider out of bounds. If they didn't, no one would be able to focus and get things done.
People often think that the failings of a system are chiefly because of the motivations of the actors in the system. But what's more accurate is that the failings are often because of the structure of the system, and the inhabitants often don't feel they have the ability to change the structure.
The least effective way to change the behavior of a system is to twiddle the various buttons and knobs that each inhabitant has ready access to. The most effective way to change the behavior of a system is to change the overall goal of the system, which would necessitate a complete restructuring.
So that's why it is easy to believe that various NSA wrongdoings aren't entirely because of nefarious motivations (although that is probably part of it), and very much driven by system structure (log and analyze data) that simply weren't "checked" as their technological tools and abilities increased over time. What many of us have failed to realize is that our own personal security has been a form of security-through-obscurity in the past. We can put personal data up on a website and not tell anyone, and before search spiders, it might have stayed private. But we can't expect such a website to stay private these days, because of how technology has increased. It's the same with our private data, and how our browsing habits can be mined to create freakishly accurate personal profiles. There was never any privacy protection there to begin with other than obscurity, and we just convinced ourselves it was there by believing in social mores that hadn't been challenged until technology increased too much.
Meanwhile, the health system was about constructing an entirely new structure/system for health insurance, benefits, and penalties.
So... I wouldn't say it is a matter of compartmentalizing. It's more a matter of appreciating that the government is a huge collection of disparate systems and motivations, and that there can be simultaneous breakdowns and successes.