Even though Germany has very clear and straight forward rules on how stars are added to its clubs crests, it is still has a unique system.
To start off we need to clarify what the German federation considers a valid championship title for this count. First of all, East German titles do not count, so clubs like Dynamo Berlin, Dynamo Dresden, Hansa Rostock or Magdeburg for example all have national titles that don't count in this case. Also, any West German title prior to the creation of the Bundesliga in 1963 does not count (highly recommend looking up what the German League looked like up until 1963).
Having established what titles count and which don't, let's get into how many titles you need for each star because it's not a linear system. The first star comes at your 3rd title, like Stuttgart or Werder Bremen. This also explains why Kaiserslautern, or Wolfsburg don't have any stars despite having won the Bundesliga.
The second star you get after 5 championships, like Borussia Dortmund or Borussia Monchengladbach.
A club can put a third star over their crest after the 10th title and a fourth star after their 20th title. No clubs in Germany at this time have either 3 or 4 stars over their crest.
Only one club right now has been able to sport 5 stars... you guessed it, FC Bayern Munich. The fifth star was awarded to the Bavarian club after their 30th title in the 2020/21 season.
It is unclear how many championships are needed for a 6th star but the speculated magic number is 50, so there's a long way to go even for Bayern.
There you have it, this is how German clubs are awarded their stars and why Bayern Munich only has 3 stars more than BVB despite having 26 titles more.