It's not punishment. The reason air travel is so safe is because every near-miss is root-caused and policies are put in place to prevent the same cause from resulting in a future accident.
I mean, yes. Every single time there’s an aviation incident there’s an extremely thorough investigation and generally a set of concrete recommendations to go along with it.
Pilots are human, automated systems fail, and the goal is to maximize safety because these fuckups mean that 200-300 people on a single plane might die (or more if a plane crashes into another or into a populated area) and these safety regulations have saved a lot of lives.