[deleted]
The division you are referring to is usually between the "civil service" (everyday government workers) and the "political appointees" (the heads and deputies who run things and set policy). You've lumped together hugely different types of services, e.g., regular civil law enforcement, special intelligence agencies, military forces (the SS), research scientists, etc., and asked about quite a few different societies/circumstances, so I doubt anyone is going to be able to answer all of these questions in one easy answer.
In the case of the Nazis, they did considerable work at the beginning of their administration to consolidate the civil service, passing laws (e.g. the Law for the Restoration of the Professional Civil Service, their first racial law), and otherwise "coordinating" (Gleichschaltung) the state so that it fit into a neat hierarchy (dubbed the "Fürher Principle"). This meant that even ostensibly non-political civil service employees were often "politicized," either overtly or implicitly, through ideological tests (they could be "denounced" by others within their departments), through expectations to join the NSDAP (Party membership was essentially required for high- and medium- level administration jobs), and so on. In many cases these various areas pre-aligned themselves with the Nazis fairly early on; opportunists and true believers used the Nazi system as an excuse to purge people from their professions that they didn't like (which is to say, it was not just a "top down" operation).
I don't know the same for East Germany but in general Soviet-style governments had similar sorts of expectations and requirements — in a totalitarian states there is no such thing as a de-politicized civil service, and, again, not all of this need to be coordinated from the top down (once the conditions are there to purge out people you don't agree with, people at lower levels tend to take advantage of them). A very eloquent (if disturbing) case study of this is Robert Proctor's Racial Hygiene, which is a description of the "alignment" of the medical community in Germany both before and after the Nazis took power. (In Germany, both medicine and universities were part of the state civil service, unlike in the USA.)
As for un-doing this sort of thing — in the areas occupied by the Western Allies, the De-Nazification efforts in theory was meant to root out who was a "real" Nazi and who was just a cog in the overall system. In reality this proved to be very hard to do both because the question is an inherently hard one and because people needed a functional society prior to completion of the efforts. So my understanding is that in many cases the same sorts of civil service people would have kept their jobs, with the caveats that some of them who were "true Nazis" would have been fired. But again this was a tricky thing.
As an additional, what about the beginning of the Nazi government? Or the Weimar government, for that matter.