Let's see how to GUARANTEE this undesired effect happening (if you do/have all or most of the things on the list):
-Unevenly cut onions
-Onions from different varieties mixed
-Pan very hot
-Not frequently stirring (or saute throwing)
-Thin bottomed pan on a hob plate with low thermal mass and weak heat coupling (glass ceramic or electric coil would be best, induction or gas in the middle since they couple harder, massive electric might make it hard)
-Bent bottomed pan on a massive electric hob plate
-Too little oil, leading to part of the onion being waterlogged and thus kept cool, part lying straight on the pan
-Stovetop is out of balance, leading to oil pooling on one side and being unavailable on the other
-Sugar in the pan
-Underestimating how much salt changes water evaporation and accelerates browning
If a couple of these conditions match, try making less of them match.