There is a widespread notion that 'saved by the bell' originated as an expression that relates to people being buried alive. The idea was that, if someone were comatose and mistakenly pronounced dead and interred, they could, if they later revived, ring a bell that was attached to the coffin and be saved.
There's no evidence to show that anyone was ever saved by these coffins or even that they were ever put to use, and there's a similar lack of evidence of the phrase 'saved by the bell' ever being used in that sense prior to it having been used in other contexts.
In fact, the expression is boxing slang and it came into being in the latter half of the 19th century. A boxer who is in danger of losing a bout can be 'saved' from defeat by the respite signalled by bell that marks the end of a round. The earliest reference to this that I can find is in the Massachusetts newspaper The Fitchburg Daily Sentinel, February 1893:
"Martin Flaherty defeated Bobby Burns in 32 rounds by a complete knockout. Half a dozen times Flaherty was saved by the bell in the earlier rounds."