The funeral of a 28 year-old waiter in southern Egypt turned into a celebration when he woke up after being declared dead. Hospital officials had pronounced dead Hamdi Hafez al-Nubi, who came from the village of Naga al-Simman in the southern province of Luxor, after he suffered a heart attack while working.
His family says grieving relatives took him home and, according to Islamic tradition, washed his body and prepared him for burial Friday evening.
A doctor sent to sign the death certificate found it strange that his body was warm. At closer observation she discovered he was still alive.
His mother fainted upon hearing the good news.
With the doctor's assistance, both al-Nubi and his mother were awakened and soon were celebrating with guests.

This makes me wonder how many people that has accidentally been buried alive like this.

I'm sure it happened plenty of times before medical techniques were modernized.
During the old ages, wakes were used to wait for a day hoping that the recently "deceased" would wake up through the sounds of the party. This is because that there were incidents during the time where several people to enter a seemly dead state and wake up soon after, sometimes in the coffins they were buried in. (This became known after people burying their dead saw scratch marks on the coffins they were reusing.) I heard a common way they became "dead" was from drinking alcohol from lead cups, poisoning themselves sufficiently enough to put them in a coma.
This became less common as we became more informed about these cases but there is certainly some fuck ups here or there.

There used to be (at some more expensive graveyards) a bell system for alerting graveyard operators, in the event someone woke from the 'dead'
A piece of string was attached through some pulleys to an individual bell next to each grave, which was tied at the other end to the hand of the person (or in some cases the toe)
And that's how some people were rescued back in those times, in the 18th/19th century

Oh and that's supposedly where the phrase "saved by the bell" comes from

Any number of reasons, they could have assumed high ambient temperature had kept him warm, that he died recently and didn't cool yet, the doctor may not have any experience in identifying if someone's dead, the hospital didn't want to care for someone they thought was going to die and instead declared him dead.
There really isn't a good reason though so I agree, they fucked up pretty bad.

Damn that would be scary shit waking up underground. I remember in the olden days when medical technology wasn't great they would attach a bell to each gravestone incase the person woke up underground they could pull the string to ring the bell.