It doesn't matter if it's bosses or co-workers, the math works out the same.
If your average team size is 5 people, then on average, the gender breakdown in your company is 72% male/28% female. I assumed 80/20, so yeah, it's still pretty accurate.
If fact, if 10% of bosses are awful then there will be far more people who have exclusively had good female bosses than bad female bosses.
P(all your female bossses awful) = P(awful boss)^(number of female bosses)
P(all your male bossses awful) = P(awful boss)^(number of male bosses)
The lower the number of male/female bosses, the greater the probability of all of them being awful. The opposite (probability of all of them being not awful) increasing is also true.
This is generally known as a small numbers fallacy[1]
https://human.libretexts.org/Bookshelves/Philosophy/Book%3A_...
There are far more male bosses than female bosses. Accordingly, assuming bad bosses are relatively rare, it's far more likely every female boss you've ever had is awful than every male boss you've ever had is awful. This is just probability.
Let's take an example. Suppose 10% of bosses are awful, regardless of gender. Further suppose that due historical societal reasons, only 20% of bosses are female. If you've had 3 different bosses in your career, there's a far likelier chance that every female boss you've had is awful (3.94%) than every male boss you've had is awful (1.4%). (I'll leave it as an exercise to derive these numbers).
So, even if men and women are just as likely to be awful, you're nearly 3 times as likely for all of your female bosses to be awful than all of your male bosses to be awful simply due to the fact that women are under-represented.
This probability may explain at least some of this common and sad bias against female bosses.