There are several ways in which a warp core failure can occur. The most common is a coolant leak, which causes a cascade failure within the system. One system failure with catastrophic consequences is a loss of antimatter containment. When matter and antimatter mix, the ship, and any matter in the surrounding area, are destroyed.
A warp core breach is usually the last in a series of systems failure aboard a starship, resulting in an irreversible event. A chief engineer or other crew member can implement a warp core ejection as a last-ditch effort to save the ship -- this is a risky maneuver and usually does not work. The captain or commanding officer may order the ship's company to escape via saucer separation, leaving the stardrive section to be destroyed while survivors evacuate in the saucer section, or, where that is not possible, egress the ship via escape pods and shuttlecraft.
In 2157, the Discovery (NX-04) nearly suffered a warp core breach while under attack by two Romulan Birds-of-Prey. Executive officer Charles Clow stopped the breach but lost his life during the battle. (Star Trek: Poseidon - The Birth of the Federation)
The Rittenhouse Incident was a warp core breach in progress aboard the USS Rittenhouse in 2291. Quick thinking by Commander Robert Lupia saved the ship, but not before seven crew including the commanding officer were killed. (Tales of the Seventh Fleet)
Early half of the century
The Sadat-class USS Accord fought off Klingon forces defending New Ruritania in 2331, but the damage to the ship cascaded into a warp core breach, destroying the ship. (Star Trek: Accord: "The USS Accord Fictional Timeline v. 2.0 beta")
Early in 2364, after being attacked by an unknown force, the USS Cerberus was destroyed by a warp core breach. Timothy Sinclair was one of a handful of survivors. (PDN: "Wings As Eagles", "Cloak and Dagger", "Memoriam", "Of Shadows and Starlight") Later that same year, two M'Tar attacked the USS Artemis, triggering a false warp core breach signal. The survivors evacuated the ship, and some claimed to see it explode. (Star Trek: The Prospect Chronicles: "False Security") In reality, the M'Tar stole the ship, and the flash was a jump to warp. (Star Trek: The Prospect Chronicles: "Lady Lazarus")
During the Battle of Wolf 359 in 2367, the USS Rebellious and USS Saratoga were severely damaged. Eleven crew, including Elizabeth Singh, made it off the Rebellious before a warp core breach occurred, killing all other survivors aboard. (Star Trek: The Cantabrian Expeditions: "An Innocent Time", "Devil's Cube") Benjamin Sisko and his son Jake both escaped the Saratoga before its destruction in the same manner. (DS9: "Emissary")
In 2371, the USS Enterprise-D suffered a core breach, destroying the stardrive section and sending the saucer section into an unrecoverable descent into Veridian III's atmosphere. (Star Trek Generations)
In 2373, the USS Cantabrian suffered a warp core breach due to battle damage fighting Samantha Delaney's Dark Starship. The crew successfully escaped in the saucer section. (Star Trek: The Cantabrian Expeditions: "By All Means Necessary")
Compromised by a computer virus in 2376, a warp core breach destroyed the Ambassador-class USS Excalibur. (NF novel Excalibur: Requiem) In the same year, a catastrophic design flaw saw the USS Independence destroyed. (Star Trek: Independence: "The Expropriation")
In 2381 the Alexandria was lost after leading an assault into the Mirror Universe and was pushed back into its own. The barrage from the Imperial starships caused extensive damage, leading to a warp core breach. The saucer section separated with the crew safely aboard. Hours later, the crew had to evacuate the saucer section after it took heavy damage from the pursuing Imperial forces. (Star Trek: Odyssey: "Distant Stars")