Dogs marking behaviour
When walking your dog be sure to allow him time to walk while not in heel position. Every dog needs to mark territory in order to communicate normally with other dogs in the neighborhood. Preventing this behaviour would be something like allowing a person to walk around the neighborhood, but blind-folding his eyes and tying his hands to his side, and not allowing him to speak to anyone he might meet. Dogs leave messages for other dogs and read the messages left by other dogs. To prevent this is at best unkind to your dog and will make him more anxious and unhappy.
When your dog has sniffed around a tree during his walk. he will usually lift his leg (males) or scootch down (females) and urinate. Your dog is leaving a marker for other dogs who will pass by. He is claiming this territory as his, or leaving a message for a particular dog. If you have a female and a male dog, the female will usually mark first and the male will mark over where she marked. This says to other dogs "paws off my lady friend".
Many dogs, nearly all males, neutered or not, and even some females will scratch the dirt with their hind legs at the same time, backing up in order to leave a longer track. This curious behaviour makes perfect sense by a dog's point of view. The dog's pads sweat, leaving a strong scent for the next dog who comes along to take note of. By scraping the earth, a dog says to who comes by next: "I am a big, tough dog, someone to be noticed and reckoned with. Here is my scent and here next to that is the size of my footprints". By making vigorous scratches in the earth, your dog shows his vitality and presumably, his size.
However, dogs are not above contriving to fool other dogs. Even a tiny dog can scratch the ground, moving backward, for a long distance. You may see a pug or Pekingeses leave a track six feet long. "My what a huge dog left this mark?" the next dog will think. Let your dog leave his mark; knowing that he will be taken note of is reassuring to a dog.