Statistically, most of the dogs in the world are dogs that are not pets, but live around humans and scavenge food or get food from humans who give it to them. These dogs are in my experience never aggressive with humans.
When a dog is kept as a pet, it will tend to be territorial about its home. When I've been out running, hiking, or cycling, there have been many times when these territorial dogs have hassled me. In nearly all cases, they acted aggressive and followed me, but never actually tried to bite me. So although it's annoying and their owners are being irresponsible, in nearly all cases all you really need to do is move on through, and nothing bad will happen.
People do, however, get bitten and even killed by dogs. Because the world has so many dogs in it, the risk is actually fairly high in order-of-magnitude terms compared to other kinds of accidents and injuries. Population-wide, your chance of getting killed by a dog is orders of magnitude higher than your chance of being the victim of a terrorist attack, but orders of magnitude lower than your chance of dying of a heroin overdose or in a car accident.
One way to protect yourself when running or hiking is simply that if a dog acts aggressive, you pick up a rock or a stick. Often such dogs will shy away even if all you do is pretend to bend down to pick up a rock. If you like, you can carry pepper spray. Personally, I bought pepper spray for this purpose and then ended up not bringing it with me on runs because it just didn't seem worth the hassle.
Many cyclists carry pepper spray. If you have a tire pump in a holder that's within easy reach, you can also pull it out while riding and use it the same way you would use a stick -- the dog gets intimidated when you swing it.
Where I live, in a city in the US, Animal Control is very responsive to complaints about dogs whose owners let them wander around acting aggressive. When a neighborhood dog was repeatedly chasing my kids, and the owners weren't willing to deal with the problem, calling Animal Control was what got them to stop. My understanding is that there's a significant fine, and they warn the owner that if it keeps on happening, they'll take the dog away and kill it. I would hate that to happen to my dog, but then I don't leave my dog running around on the street biting kids.