The mass structure of large objects determines what the astronomical life cycle of the object will be. For instance, consider our Sun. If a stellar object has the equivalent mass to our Sun, it could collapse into a white dwarf. If the object is up to 3 times as massive, it could compact into a neutron star. But if it is more than 3 times as massive, it will collapse into a Black Hole.

click to enlarge
Source: http://imagine.gsfc.nasa.gov/docs/science/know_l1/supernovae.html
Why the collapse?
While a star is burning, it counterbalances the effect of gravity. Stars have a lot of mass, and they are not solid, but gaseous, so to prevent a star from collapsing onto itself, the burning energy provides a counter force to gravity. However, a star will eventually burn itself out and the effect of gravity will take over. So, if the remnants of the star are as massive as our Sun, a white dwarf forms, more massive, and a neutron star forms, and greater than 3 times as massive, a Black Hole forms.
When is there a Supernova explosion?
The process that burns the gas on a star, the nuclear process, however, is not tidy. Young stars are made up largely of hydrogen, and the nuclear fusion reactions converts the hydrogen (1 proton, 1 electron, 0 neutrons) into helium (2 protons, 2 electrons, 2 neutrons) with heat and light energy left over. As the process continues, most of the hydrogen will be converted to helium, and a new nuclear reaction begins which converts the helium to carbon (6,6,6), with the left over energy radiation. This process continues converting the carbon to oxygen (8,8,8) to silicon (14,14,14) to iron (26,26,30). Nuclear fusion ends at iron.

click to enlarge
The process continues. However, if the star runs out of fuel, the gravity could be so strong to collapse onto itself, yet as the outer layers collapse, they bounce off to create an explosion, which we see as a supernova.