Wikipedia:
According to an urban legend that has no basis in fact and is practically unknown in Germany, Kennedy made a slightly embarrassing grammatical error by saying "Ich bin ein Berliner," referring to himself not as a citizen of Berlin, but as a common pastry:
"Kennedy should have said "Ich bin Berliner" to mean "I am a person from Berlin." By adding the indefinite article ein, his statement implied he was a non-human Berliner, thus "I am a jelly doughnut"."
The legend stems from a play on words with Berliner, the name of a doughnut variant filled with jam or plum sauce that is thought to have originated in Berlin.
In fact, the statement is both grammatically correct and perfectly idiomatic, and cannot be misunderstood in context. The urban legend is prevalent only in English-speaking countries but largely unknown in Germany, where Kennedy's speech is considered a landmark in the country's postwar history..... Similarly, after 9-11 many politicians said "today we are all New Yorkers" and nobody thought they meant "we are all glossy magazines" or "we are all cars."
The citizens of Berlin do refer to themselves as Berliner; what they do not refer to as Berliner are jelly doughnuts. While these are known as "Berliner" in other areas of Germany, they are simply called Pfannkuchen (pancakes) in and around Berlin.
So, in summary, what Kennedy said was perfectly correct and understood by Germans.... and people in Berlin do not call jelly donuts Berliners anyway.