Yes Germany wasn´t a real nation for so many centuries, only like an alliance of smaller states. Then after Napoleon they wanted black-red-golden, because there was a small army with an uniform having that colours, that fought for freedom. But when Prussia united most of Germany 1871, they took of course their own colours (black-white) + the colours of the north german Hanse cities (red).
After the Kaiserreich, the first german republic got black-red-golden.
in the 3. Reich they used the swastica flag and 1949 again the black-red-golden one, until now^^