The rationale is that it's too easy for politicians/officials to hide things from the public by arbitrarily declaring things as "secret", and that the public has the right to know about this stuff.
[0] https://en.wikipedia.org/wiki/New_York_Times_Co._v._United_S...
These entities care for nothing but power, vying for it every moment, corrupting everything they can corrupt to get more of it.
It is essential to have a spotlight on them exposing when they go too far.
In other words, why shouldn’t we punish whistleblowers?
Because otherwise we would be on a fast track to an authoritarian dystopia.
Journalists don’t give up their sources due to the risks you are highlighting.
Anyway - for a open society to function we need to live in the same factual world and media contribute to that.
Both are based in the first amendment. IMO the press protections are a more legitimate application, particularly wrt to information that is ultimately about public policy.