To understand why flag burning is prohibited, you need to understand this in the context of the fact that, in general, free speech protections in Germany are not as broad and absolute as in the United States.
No country in the world makes heavier use of criminal defamation offenses than Germany, and being unnecessarily insulting without making a false statement of fact can give rise to criminal defamation liability in Germany. I discuss this at length in an answer at Law.SE. Some highlights from that post:
In Germany, you usually don't even need to hire your own lawyer to sue
someone for defamation. Instead, often a government prosecutor will
bring criminal charges at public expense against someone who allegedly
defamed you.
Roughly two hundred thousand criminal defamation cases are
investigated by law enforcement each year in a country with about 25%
of the population of the United States.
Merely insulting someone in public in Germany is a misdemeanor
and such cases are seriously investigated when they
involve high government officials including foreign ones. For example:
"In 2007, a Swiss citizen living in Bavaria was convicted of insulting
Swiss President Micheline Calmy-Rey and sentenced to pay a criminal
fine."
Similarly:
"The Beleidigunggesetz, or law protecting people against insults, isn’t
always enforced, but certainly can be. “The law against insulting
another person in public has been on the books since 1871, and it can
be taken quite seriously in Germany,” said Volker Schmitt, a lawyer
based in Berlin.
Paragraph 185, Section 14 of the criminal code still reads almost
exactly as it was written 145 years ago: “An insult shall be punished
with imprisonment not exceeding one year or a fine and if the insult
is committed by means of an assault with imprisonment not exceeding
two years.”
“The law is designed to protect people’s honor,” said Karsten Gulden,
a lawyer who specializes in the issue. “Respect for people and their
reputation enjoys legal protection, and shouldn’t be verbally
violated.”
There were 218,414 cases of insults filed with prosecutors in Germany
in 2015, down slightly from 225,098 in 2014, but far above numbers of
around 150,000 recorded a decade ago. Americans and other foreigners
living in Germany sometimes run afoul of the law, unaware of it, and
end up being called into police or prosecutor’s offices to explain
their side of the story, before their cases are usually dismissed.
Hardly anyone ends up in jail for insulting their neighbor in the
midst of a heated dispute, or for flashing the middle finger — the
Stinkefinger, or “stinky finger,” as Germans call it — at another
motorist in heavy traffic. But cases do wind up in court and fines are
sometimes handed down.
In a precedent-setting 1995 ruling, a Schwaebisch Hall court awarded a
man 460 euros over racist comments against his wife, who is black. In
1997, a boss who called a pregnant employee “Germany’s laziest worker”
in an in-house magazine was fined 2,500 euros. In 1998, a court in
Heilbronn awarded a police officer 350 euros after another person
called him a “wanker.”"
It is a felony punishable by up to two years in prison to speak ill of
the dead in Germany, even if the statement is true.
In contrast:
Between 1992 and August 2004, 41 criminal defamation cases were
brought to court in the United States, among which six defendants were
convicted.
From 1965 to 2004, 16 cases ended in final conviction,
among which nine resulted in jail sentences (average sentence, 173
days). Other criminal cases resulted in fines (average fine, $1,700),
probation (average of 547 days), community service (on average 120
hours), or writing a letter of apology.
In general, one way to summarize Germany's attitude towards free speech is that in Germany that right does not extend to abusive, insulting, or hateful communications, even if they aren't false statements of fact, in much the same way as most countries don't provide legal free speech protections to imminent threats
Put another way, Germany enforces genuine civility standards as a matter of criminal law. In that context, a ban on flag burning isn't surprising.
It is also helpful to understand that in Germany, most misdemeanor and minor felony sentences, such as sentences for flag burning, insulting the dead, or defamation are usually carried out, not in the form of actual incarceration, but in the form of "day-fines" with the fine equal to roughly one day's income (less some minimal necessities) times the number of days of incarceration authorized by law, with the fine actually imposed frequently being much more lenient than the maximum punishment authorized by law.
Thus, it wouldn't be unusual for a sentence for a crime for which a three year sentence is authorized to actually amount in practice to a 2,500 to 20,000 Euro fine whose exact amount would be established, in part, based upon the income of the person fined, and in part, in the discretion of the court.
This is one of the reasons that the incarceration rate in Germany is so much lower than in the United State.
Historical Basis
Some of this attitude towards free speech in Germany arises from a desire to de-Nazify Germany after WWII, but it also has much deeper roots in German political and legal culture about the appropriate scope of government.
In the same vein, in the Kingdom of Prussia, which was the largest of the antecedents to the German state that was unified in the 1870s, there was a statute decreeing when people were to do their laundry and other fine details of daily life. It was the sort of place where rules of etiquette that have no legal effect in common law countries like "don't wear white after labor day"(this particular one wasn't a Prussian law but is similar to many laws that it did have) might be enforceable as a matter of criminal law rather than merely being a socially enforced suggestion.
Germany's laws, in general, have historically been oriented towards what should be expected from a "good person" rather than following the English political theory tradition that government should intervene by law only to the minimal extent necessary to maintain order and a functioning society.
Freedom of Religion Compared
This attitude isn't limited to freedom of speech either. As another example, Germany has a strongly protected freedom of religion, but in a much more regulated way than would be tolerated under the United States Constitution.
For example, you have a right to declare your affiliation with any religion you wish in Germany. But, if you want to change your affiliation you have to file an official form with the government (which changes the denomination to which your government collected "church tax" is paid), acknowledge that you have received certain written warnings about the risks of doing so, and provide proof that you have attended a session with a member of the clergy in the religion or denomination you are leaving. At that session you will be warned, for example, that you may face damnation, will disappoint your relatives who aren't changing their religious affiliation, and won't be able to be buried in religious cemeteries of your old faith any more, in the event that you go through with filing your application to change your religious affiliation.