I don’t know about Portugal. But Amsterdam’s drug toleration (it’s still illegal mind you) happens against a background of pretty intense anti-drug culture. As that culture has become more permissive, drug policy has become more punitive: https://www.journals.uchicago.edu/doi/10.1086/681551