Ladybeetles are reasonalby similar in two stages, so many larval structures are retained in the adult, but in Diptera, almost total reorganization of the body takes place. In the pupal stage everything larval is broken down and body is remade from imaginal discs and other similar internal groups of cells. Escape from pupa . Pupa splits along a line of weaknesss, due to the insect pumping fluid from the abdomen into the throax and head. Sometimes have specialized pumping structures like flies.
Many insects have teeth, ridges on the head or other structures to help tear open pupa or cocoon.
Many insects which do not feed as adults have mandibles anyways, just so they can get out of the pupa. Some insect produce softening secretions just before emergence to break down the cocoon.