It sounds funny that he would be eating it, but nonetheless, he might be missing something in his diet that he is finding in the soil, change his diet to another food, and then if this continues, I would take him to the vet to find out why, if you can, and what to do about it. Hope this helps, good luck.
To answer your first question "why does your dog eat dirt" can simple be answered, because they might not be getting sufficient vitamins or minerals. You should ask the vet to give you some. About your dog, who died last night let me tell you that the tiny stones or rocks present in the dirt or ground can be really dangerous for the dog as they can get lodged in dog's stomach or intestines. You need to take care about this now.
Dogs do this all the time and they also eat grass to make themselves sick when there not well I wouldn't worry unless he is eating any poisonous plants or soil with weed killer or ant /slug pellets
My dog eats dirt and plants all the time. It's just a natural habit.
My dog eats dirt and her poo. She seems to be eating more and more dirt. Then she throws up ... Mud like puke with a terrible odor. Why is she doing this and how can I treat her?