Important part is that it is the countries spying in each other not private individuals.
This gives the spy protection as both sides are spying on each other so usually what happens is some snarky comment/strongly worded letter and expulsion of a few spies back to their home country from both sides.
In the worst case someone goes to prison but usually in response the other side also finds some spies to put into prison too as "revenge".
Also whatever information the spies manage to get in general is not released to the public.