At least in the US, there is a systematic separation of concerns and quite a few authorization interlocks. These are intentionally designed to make it nearly impossible for a rogue unit to operate with legal cover. Everybody who is a part of that legal process takes their bit very seriously and it isn’t just a bunch of political appointees.
Some types of operations require explicit and direct sign-off by the President, which provides legal sanction for people doing the work. Even in these cases, the operational details are left to the career professionals.
That isn’t to say that organizations can’t leave the reservation (see: FBI under Hoover) but that over time they’ve built up a lot of internal structure to limit it with varying degrees of effectiveness. It is useful to note that almost all of this was invented out of whole cloth after WW2, so the US has had to learn a lot of lessons the hard way.