That's generally because those diplomats can't be tried for their activities in the host nation, and also because said diplomats are running spies, not stealing secrets themselves.
In other words, they aren't the traitors, their agents are. And those agents are the ones who get tried in the media circuses we're all so familiar with.