The behavior of eating dirt or other non-food matter is called pica. Horses can eat dirt for a variety of reasons. Some of those reasons are medical in nature, so I would recommend a full vet exam before any other intervention. If the vet exam is clear, talk to your vet about the amount of salt and other minerals your horse is receiving to see if there may be a mineral deficiency. Some horses eat dirt when there is little or no forage available. If your horse is in a dirt yard as opposed to a grass pasture, make sure there are several hay stations available, and that at least a couple of the hay stations are on the ground.