Consider a country in the third world where there is a lot of hunger and poverty. Suppose that there are no laws or customs against killing dogs, that firearms are somewhat common (say, 20% firearm ownership rate), and that almost everyone has an axe or a machete. Why might there persist sizable populations of feral dogs in both urban and rural areas? One would think that hungry people would quickly hunt the dogs to extinction. A determined group of humans armed with machetes and axes should be able to corner and kill a dog without too much issue, anyone with a gun should be able to do it even easier, and leaving out food spiked with pesticides should also do the trick. As meat is likely to be a rare delicacy in such a country and as even a single dog likely contains tens of thousands of calories, hunting dogs seems like it would be a logical option in such circumstances. So why would would dog hunting be rare in this country?
Dogs are sacred or otherwise culturally taboo.
In the US people would need to get really hungry before they would start eating dogs, and that's just due to general affection. If they were sacred, like cats in Egypt or cows in India, the taboo would be much stronger.
Some authority prevents it
Not worth killing a dog if your totalitarian government is going to kill you if they find out.
Disease or parasite
If even 10-20% of dog meat carries a life-threatening parasite/disease, it wouldn't be worth eating them except in life-or-death circumstances.
They eat domestic dogs instead. Feral dogs are domestic dogs which have gone wild (obviously). If you want to eat dog, it is much easier to keep a few in a pen, feed them on scraps and kill one for meat when you need it, than it is to go hunting a pack of feral dogs. You don't even need to feed the domestic dogs on meat. IIRC one of the Polynesian cultures fed their dogs on fruit, because they said the dog meat tasted better that way.
The population of feral dogs is constantly replenished from the population of domestic dogs. Unwanted dogs are turfed out onto the streets. Dogs run away from owners they don't like. Owners just let their dogs run free, and some of the bitches will decide to have their litters away from the owner's house.
You can't tell if the dog is feral or free ranging, and people get mad at you if you kill and eat their property. As recently as the 1970s there were packs of dogs running lose on the streets of some of the UK's cities - these were a mix of feral dogs and free-ranging owned dogs. If your society doesn't have rules and regulations saying that your dog has to have a collar, a microchip, be spayed and/or you need a dog licence to own one, then you can't tell if that scruffy mongrel is a feral dog or has an owner.
There is something horrible you can catch from eating feral dog meat. Rabies. Liver fluke. Galloping space lurgy. Invent a disease - or the belief of catching a disease - from eating dog meat. Perhaps everyone 'knows' that you get malaria if you eat dog meat in the wet season, because they are clueless about mosquito bites passing on a parasitic infection.
The dogs know they are being hunted. Feral dogs (and feral pigeons, urban foxes, ducks in the local park, etc) aren't wary of humans because 99% of humans ignore them. If the dogs are regularly hunted, then they'll make themselves scarce. They'll become nocturnal. They'll flee from humans the way wolves and deer flee in areas where they are regularly hunted.
The people have hunting laws/customs designed to avoid the dogs being hunted to extinction. If the dogs are a valuable source of protein, there may be customs to try and prevent them being hunted to extinction. These customs may, of course, break down in a famine.
The dogs breed faster than humans can wipe them out. Possibly the dogs just out breed the humans' hunting efforts. Or the dog population may indeed be on a downward spiral, but it is a slow and steady one, not extinction in one person's lifetime. Great-grandpappy bores everyone with his tales of how there were thousands of dogs on the streets in his youth, when plainly you can see that there are just hundreds.
There were many more people in the recent past.
This country has suffered a war, genocide or disease event which has depopulated the countryside. The abandoned farms and orchards support large numbers of rats and deer and the feral dogs live on fruit and rats. There are really a lot of dogs in the countryside and population pressure pushes them into the city.
Population density is high in the city and any city with a high population density will also have many rats. The dogs moving in from the countryside are accomplished ratters and can sustain themselves thus. People do try to shoot them when they can find them. These dogs are stealthy, nocturnal and fast, much like coyotes.
As regards rifles, if I woke to hear some idiot shooting at dogs in the alley outside my house, I might be inclined to get mine and shoot him. Walls are too thin to keep out bullets.