I think in both countries these methods are supported by actual laws, one via "advertising-exclusion systems" that the companies need to respect, and in Sweden via the Swedish Marketing Act which forces companies to not call people who've "clearly objected to that method" or something similar. I'm sure similar laws and lists exists in other countries too. Obviously hospitals, doctors, utility companies and similar don't cross-reference against these lists, as they have actual relationship with you already.
Both in Sweden and in Spain I used to receive a lot of spam calls, like multiple per week, and once enrolled on these lists, the calls are non-existent, the only telemarketing calls I get now are from the companies I already have relationships with, which happens maybe once a month.
If you suffer greatly by the constant spam calls, like I did once before, do take a look and see if there are similar opt-out lists in your country :) They may take a month or two before actually eliminating all calls, but they do work, apparently.