The gambling thing is a bit different, normally it's the sites that cooperate like that so that they have a chance to be able to become a licensed provider in that country in the future. It's a strange trend in that industry that also goes counter to various trade agreements, but that's just how it goes. That said countries can also take action locally against foreign entities they believe are breaking their local laws, and go after their local assets, e.g. they could seize their .es domain names or take action against any local office or other assets that they have.
Same with consumer laws, those apply if I buy a product in other country. For example Spanish law says I can get a refund 7 days after the purchase, no reason required.
Yea, doesn't make sense and probably they can't enforce many of these, but that's how they are redacted. I would set the legal team on alert mode if I were Reddit/Twitter/Facebook/Menéame.