Dogs eat dirt all of a sudden for a variety of reasons.
Usually the reason that dogs eat dirt all of a sudden or at any time is because of a low iron count, anemia or other mineral deficiencies.
The dog could just like the taste of the dirt as well and just enjoys eating the dirt and as long as the dog doesn't swallow a rock that would choke them the dirt eating in the dog is not harmful.
Yes it's safe for dogs to eat dirt.
Dogs usually eat dirt because of anemia or rare iron or mineral deficiencies.
Sometimes it's just the dog being bored and wanting to eat the dirt and it's not harmful to the dog unless the dog happened to eat a large enough rock to cause choking.
Even kids eat dirt sometimes as toddlers and I remember when I was 3 and 4 years old that I would go outside and eat dirt with a spoon.
I once got a rock in my mouth at age 3 and my mom had to get it out of my mouth but I was okay and yes I did swallow the dirt I ate but not the rocks.
So just like humans who eat dirt as kids and toddlers a dog eating dirt will do them no harm either.