It appears the blowout that caused the explosion occurred between tasks, perhaps when no one was actively monitoring the wellhead. The escape of polluting oil occurred because the blowout preventer failed to automatically close and failed later attempts to manually close. Perhaps it was frozen. The operation of equipment at those depths and temperatures may not be fully understood. It's all done by robots and remote control. Except for the pollution, it might as well be on the moon.
Folks are already looking for a scapegoat, someone to get the blame. I suspect the Gulf blowout falls in the category of 's**t happens,' and if there is fault or blame, it should be placed squarely on us all because of our gluttonous need for petroleum.
The Gulf of Mexico has always been a dangerous place to drill, and drilling in ever-deeper water has added to the danger. A blowout can occur when the drill encounters a pocket of natural gas or a gas bubble locked in the formation suddenly bursts into the drilling column. Since they weren't drilling when the blowout occurred, the latter situation probably happened. It's also possible that the cementing operation was faulty.
Blowout situations are avoided by keeping a tight control on the density of the drilling fluid and making sure that the downward pressure due to the hydrostatic column of drilling fluid in the wellbore remains greater than the pressure of oil and gas pushing out of the formation.
In a blowout, the bubble of natural gas mixes with the drilling fluid. This lowers the density and upsets the balance. In a severe blowout, the expanding bubble of pressurized natural gas will push everything out of the well bore, shooting a string of drill pipe like a rifle shooting a bullet. Gravity makes the next few minutes an exciting time.
Since in this case, they had just finished cementing in the well, there wouldn't have been drill pipe to contend with. Often the exiting natural gas ignites and causes an explosion.
More information can be found in the links.