Here is an article about dogs in public places: https://www.snau.es/blog/donde-puedo-ir-perro-segun-ley/
I suspect that like many laws it is the minority that spoil it for everybody else…Not all dogs are as well behaved and trained as your is.
I also recall an incident in Guadalajara where an owner was attacked by a cow with its young almost killing the dog in the process. And a little dog that was taken by an eagle in Monfragúe National Park
Breathe and try to be nice to people 🙂