I don't think I've ever had a TPK outside of running one offs of tournament modules that are designed to produce TPKs, as usually at least one swift PC has been always able to escape the wreckage.
However, the general pattern of PC deaths has always been the same. In order of frequency:
a) Split the Party: This is the leading cause of PC death. In my current campaign (6+ years), of the 11 PC deaths, 9 in some fashion involved splitting the party, including the two days of disaster that lead to near TPKs that account for like 7 of the 11 PC deaths.
b) Party Cohesion Breaks Down: This is the leading cause of splitting the party. Operating as a unit, a typical PC party has the resources to win just about any single combat. When players become frightened though, most often because they are uncertain of the threat they face or what tactics they should attempt or if there is an intraparty disagreement over tactics, they tend to start thinking in terms of every man for himself. This results in PC's abandoning allies, with the result that the enemy is able to concentrate forces on a single PC, leading to a domino effect where each PC falling both reduces the ability of the party to handle the foe and further reduces party cohesion. The party routs, leading to the party splitting and often any or all of the additional complications listed below occur during the rout.
c) Party Failed to have an Exit Plan: Inevitably the party is going to get in over their head. This isn't always a problem, as parties can always fall back in an organized fashion and either outdistance their attacker, or put obstacles in the attackers way that break the pursuit long enough to get out of the situation. Deaths tend to happen when the party has to fall back, but has failed to clear obstacles in the path behind them - such has having entered through a vertical shaft, pressed forward through an area without clearing it, left traps in their own path, and so forth. The less mobile members of the party are unable to fall back with the group, causing the party to split, leading to deaths. Often made worse in a failure of party cohesion, as party members throw up obstacles or deliberately use paths of retreat to deter pursuit that are also obstacles to other party members.
d) BBEG: Since any fight with a BBEG is supposed to be dramatic, the encounter is usually balanced on a knife edge and bad luck can easily kill one or more PCs. This is particularly true if the party has been reckless with resources prior to the fight, or fails to respond appropriately to the threat the BBEG presents. Often a PC will die in the first round or two before the party as a whole adapts to the situation, and "goes nova" in an appropriate fashion. This is one of the few cases where deaths tend to happen that don't involve splitting the party, but they are almost inevitable if the party does split and then runs into the BBEG.
e) Room Traps: A party that pushes forward recklessly in to a room trap can find itself in over its head in a hurry. This is particularly a problem if the party split up, and only a fraction of the party has to extract itself on its own. Finding that you don't have the skill monkey to disarm the trap or open the doors, or don't have the healer to staunch the bleeding or restore the critical party member to consciousness, or don't have the spell-caster to invoke a change in the scenario, or don't have the brute you need to break something when a trap is trying to kill you pretty much means someone or everyone present is going to die. A couple of times though parties have been rescued by having a player just outside of the area of effect of the trap (for example, buried in sand traps), so there is a tradeoff here in staying together and still having enough tactical separation to avoid area of effect attacks.