Why did a lot of common insects evolve such a thin waist?
This thin waist is called petiole (aka.  wasp‐waist).

How many times did the petiole evolve?


  Why did a lot of common insects evolve such a thin waist?


Reading this question make it feel that you are assuming that several lineages evolved this petiole independently. It would be wrong. The petiole evolved once only and all the species that are having a petiole today (ants, bees, wasps, ...) are descendent of this lineage that evolved this petiole.

The taxon of all these species having a petiole is called Apocrita, which is a suborder of hymenoptera. You can learn much more about the phylogeny of these taxons in Rasnttsyn and Haichun (2010).

Why did it evolve?

The early lineage who evolved this trait where parasites (or even parasitoids at that time, I am not sure). This lineage was laying their eggs in tree trunk (or maybe already in other insects larvea if they were already parasitoids). The constriction that is the petiole allowed these individuals to have greater maneuverability for depositing their eggs accurately (Peters et al., 2017; Wilhelmsen et al., 2010).

The evolution of this petiole greatly affected the future evolution and diversification of Apocrita as things like stings and even maybe eusociality. From Peters et al., (2017)


  The evolution of the wasp waist, a constriction between the first and the second abdominal segment greatly improving the maneuverability of the abdomen’s rear section, including the ovipositor, was a major innovation in the evolution of Hymenoptera that undoubtedly contributed to the rapid diversification of Apocrita