After a massive recall, Samsung instructed 700 researchers to test over 200,000 smartphones and 30,000 batteries to find the root of the problem. The company established without a doubt that the issues were caused by two different manufacturing defects.
The incidents with the original phones were caused by a design issue: insufficient space in the battery resulted in bent negative electrodes in the upper-right corner of the battery. Furthermore, the tip of the negative electrode was incorrectly located in the curve, not the planar area. These issues resulted in a short-circuit that set Note 7 batteries on fire.
The second problem reads like Murphy's Law. Basically, in the rush to get as many Note 7 replacement devices on the market, a lot of batteries made by a third party ended up with major manufacturing defects that resulted in a similar short-circuit issue. Samsung discovered the second battery type had high welding burrs on the positive electrode, which resulted in penetration of the insulation tape and separator layers. Furthermore, a number of batteries were found to be missing insulation tape. Both factors enabled a short-circuit which also set batteries on fire.
To make sure this will never happen again, Samsung implemented a new 8-point battery safety check and made several other enhancements to its quality assurance process. Full details can be read at Samsung.