I don't really see them in the same niche; I like the ESP32 as a general purpose, powerful, not-on-batteries option, while ST gives me lots of options so I can find a microcontroller that fits the specific project needs well without a bunch of extra stuff to worry about turning off. In general I think you have a lot more control with STM32 than you do with ESP32, not just in picking your parts but in fine control of the microcontroller. But, I'm not an expert in either, I just fool around.