It's unavoidable, and it happens for several reasons:
1) Lower-rung proles in the organization feel a need to show off, that they're part of a powerful organization, and so they'll blab - "hush hush" and off the record of course - about some meaningless little piece of trivia that actually angers enough people over in Congress to make it an embarrassment. It's usually minor, partisan or political posturing stuff that never compromises national security (often because the leaker in question doesn't have clearance for the serious shit anyway). You still see somebody losing their job over this once the higher ups figure out who could have been in the loop for that tidbit.
2) There's a possible shift in how the federal government will do things, so the West Wing issues a deliberate leak - often through a trusted reporter, and done through an informal chat - to see what the response would be. You can tell how "official" the leak is by how the unnamed source is ranked: Senior Advisor for example will outrank Senior Spokesperson. The rank will flag Congress' notice as to how serious the White House is pursuing the policy change.
3) There is a likely shift in how the federal government will do things, but there's a faction within the White House - one of the agencies - concerned about its direction (or even its legality). This is where the whistleblowing comes in, and this is where it gets serious. At this point, you have to worry about national security - especially if the leak involves foreign policy or military actions - and how high both the dissenting leaker and the policy advocates are on the chain of command.
4) The leaks are coming during a period of mismanagement and misdeeds within the administration. There's so much chaos and stress within the West Wing that people are spilling their guts to their Beltway media friends in order to A) cover their ass to deflect any blame for incoming disasters, B) point the blame towards rivals (and sometimes even the guilty party) elsewhere in the office, C) vent their frustration about the idiots in charge, AND/OR D) add to the chaos and anarchy to make their bosses' lives more miserable.
Guess where Trump's White House falls on the list? Yup. Fourth. On the list. The chaos one.
Per the Balloon Juice daily roundup of schadenfreude (which actually links to a Politico article):
Last week, after Spicer became aware that information had leaked out of a planning meeting with about a dozen of his communications staffers, he reconvened the group in his office to express his frustration over the number of private conversations and meetings that were showing up in unflattering news stories, according to sources in the room.
Upon entering Spicer’s office for what one person briefed on the gathering described as “an emergency meeting,” staffers were told to dump their phones on a table for a “phone check," to prove they had nothing to hide...
The irony that Spicer's witch-hunt among his own staffers to find leaks was itself leaked to the press should not be lost to history.
Spicer is likely to find some of the less competent leakers, but he's not going to succeed on cutting off every outlet because he's dealing with others in the White House - in other offices and agencies - outside of his control who are still able to whisper stuff out to people, and using methods well-honed over decades of interoffice backstabbing that can't be easy to track.
Like it or not, Washington DC is a company town and rather insular: too many people are connected to too many sources. Kind of like the Six Degrees game: you can link Jake Tapper to someone in the State Department command structure by three people, you can link Rachel Maddow to someone in Justice by two, that sort of thing. Cutting off those kinds of communications is next to impossible not without shutting down everybody's social lives. Even threatening to do so can backfire by driving the whisperers into dishing out bigger tales of interoffice ineptitude - and maybe criminal behavior - before they get the boot.
All Spicer - Spicey? Spices? I'm keen on making him the next Spice Girl and labeling him Yelly Spice - is going to do with this leaks investigation is give Saturday Night Live more material for the next fresh episode.
It'd be funny except for the fact this is our federal government sinking like the Titanic. This is not pretty, and it's gonna build up to something explosive...