Earlier quoted context omitted.
Much of what intelligence services do is a violation of local laws. Those other countries are free (and often do) prosecute any responsible agents of other countries for breaking their laws on their soil if they want to. They can convict them for these crimes, but if they didn't manage to catch them before they return home, then they are unlikely to ever be extradited. This can also have diplomatic consequences, affe…
IANAL, but aside from local laws, aren't there international laws or treaties that's supposed to stop countries from spying on each other's embassies?
And even in that case it's kind of common, well accepted practice to use embassies for spying on the host country. There are boundaries on what's acceptable (violations of which will have a diplomatic response or expelling all the involved and perhaps some random personnel), but nobody's really shocked if they happen to find that half of embassy stuff are there mostly for espionage tasks.
"International law" is not really equivalent in practice to ordinary law (which generally has the state monopoly on violence backing and enforcing it), it's more like countries have voluntarily agreed that it seems best that they should follow a particular set of practices. But they aren't required to - the main driver is that if you violate some norms, then others are likely to violate these norms against you. A treaty doesn't stop a country from doing something, a treaty is an indication that the involved countries believe that it's in their best interest if they all avoid doing that... but they'll be able to withdraw from that treaty (either legally, or in practice by simply doing the 'prohibited' thing) whenever they think it's best.