MacBook DNS works behind some routers, doesn't behind others
You have statically set network adapter settings (IP address, DNS server, etc.) and you are moving between different networks.  Keep in mind, though many networks are similar in configuration, no network is exactly alike.

There are many different reasons why you experienced what you did, and it would be impossible without actually looking at your individual configuration, but suffice to say the static setup you had working in one network wasn't exactly right for the other network and may have been good enough for the third network, and so on.

This is why it's good (among other reasons like IP address conflicts), when going between various networks, to obtain the network settings via DHCP.  This way, there can be no conflicts.