After World War II the occupying forces in Germany started a program of "Denazification." The idea was to basically go over anyone who had any significant role in Germany during the Nazi period and have a tribunal of sorts about the extent of their "Nazi-ness." Obviously this was a tricky sort of thing to suss out at times — people nearly always claimed that they weren't really Nazis, that they were just playing along, that you can't live in a totalitarian state and be actively opposed to it without putting your life in peril, etc. The tribunals would rank them depending on their involvement, and there could be serious sentences (death could be the worst; but even for much lower ranks, there were sanctions against running for political office). Some millions of Germans were basically disqualified from political office and even professional jobs.
In practice of course this got very tricky — there were a lot of people to process, evidence was often lost or destroyed during the war, the country had been split in two and witnesses could be hard to track down, and the Germans themselves were never too keen on this approach. And they did require people to help run and work in the country in the meantime. One of the hallmark Nazi policies, Gleichschaltung, basically made all professions (lawyers, doctors, even veterinarians!) into streamlined, politicized arms of the Nazi state, so unless you were wiling to say "Germany will have a generation without doctors" it would be very difficult to actually restrict all people who had benefited from and taken part in the Nazi rule during those years. So corners were cut, things were expedited, people were sometimes let off pretty easy even if they had been pretty unpleasant during the rise of Hitler. By the early 1950s the program was ended.
The above only applies specifically to the American Zone. There are different approaches in the zones administered by other countries. The Soviets did a much rougher version of the above, but they also were more willing to turn a blind eye to Nazi criminals if they were useful to the new regime. So it became quite a trope that your Stasi officers would have had Gestapo experience, for example.