"Ich bin ein Berliner," stated in Berlin, is not open to misunderstanding. In Berlin, 'Berliner' does not mean doughnut: in and around Berlin, a doughnut is called a 'Pfannkuchen.'
Elsewhere in the German-speaking world, 'Pfannkuchen' means pancake. The term 'Berliner' was originally short for 'berliner Pfannkuchen' so the origin of its use as a term for a food item is similar to that of frankfurter, hamburger, and wiener.
In Berlin a pancake is called an 'Eierkuchen,' which elsewhere means omelette. In Berlin omelette is called 'Omelette.' (That's the French influence for you).
It's all quite simple, as long as you remember where you are.