There is a lot of information describing this that goes very deep into the breakdown of it all. To make it easier and give you the basics I have broken it down into an easy to understand infographic.
In short, bad bacteria has a weak outer shell allowing the essential oils to get in there, change or break down the composition of the cell. The many constitutes of essential oils (a few are highlighted below) will break down different parts of bacteria. This invasion and breakdown done by essential oils prevent it from either replicating or destroying the bacteria altogether. While good bacteria has an extra and thicker outer shell that protects it from invasion. As a result, this makes it much harder for essential oils or any other foreign body to penetrate it.
I hope you found this useful and informative!