Look up the idea of a national airline, a flag carrier, and drop your attitude that for whatever reason they should have been banned from operating because they had been such.
Aeroflot carried the flag of the USSR proudly, the USSR killed more people than Nazi Germany ever did. Totally irrelevant. They're their country's flag carrier, so they show the flag.
Anyway, this has nothing to do with anything military. Lufthansa was state owned at the time (and indeed into the 1990s), so of course they flew the then current flag of the state, which for a decade happened to include the Swastika.
Also, the post-WW2 Lufthansa is a different company from the pre-WW2 Lufthansa. It was incorporated in 1953 and purchased the name Lufthansa on the open market as a trade name, an old and proud name in European aviation, a name associated with quality and reliability.
They still bear the national flag of Germany to this date, albeit a smaller one. But at the time it was very common for airlines to show the national flag very large and proud on the tail fin or fuselage.