My grandmother passed away in her sleep and vomited a lot of coffee grounds, what could have caused that?

Unsure. I am not sure why she passed away, but coffee ground is a sign of gastro-esophageal bleeding (causes of GI bleed may include, gastric ulcer, gastric cancer, esophageal varices etc.).