I think it might be a problem of cultural background and habits.
Where I live, it is very rare to see a dog roam around without its owner close by. If you find a dog here that is not accompanied by an owner, it is assumed that it is lost or homeless, and it's normal procedure to take it to a shelter (we don't have kill shelters here, so it's an easy decision since no harm will come to the animal), so it can be reunited with its owner or be adopted by someone else.
Also, in other countries owned dogs might not look as well cared for as one might expect from one's own country.
So the combination "roaming around all alone" + "not looking well groomed" + the fact that spain is a country that is (at least where I live) somewhat renowned for having many strays (prejudice?) might give some people the impression that the dog is homeless, while in fact it is not. And so they might think it's better to take it with them and bring it to a shelter than leave it behind. Not excusing the behaviour, just trying to find an explanation.
When I walked last year I noticed many flyers and posters that informed pilgrims about this problem. I think that's a good approach.
If all dogs were chipped and registered, that would also help reunite dogs with their owners when they accidentally get separated, may it be because of a pilgrim who misinterpreted the situation or something else.