I found this page explaining that it's not that it's illegal (necessarily, keep reading), but that there is a GDPR exemption for private property and if you're filming areas the public access then you need to comply with GDPR. The page says for dashcams you need to comply with GDPR as well.
This page says it's generally not allowed to record, but if you read the Swedish version it has a flow chart (that I can't read 😅).
What most interests me is that it keeps referring to the GDPR as the reason why you can't record public areas (or your neighbours). I'm not in Europe and don't know much about the GDPR but why is Sweden special with these rules, why aren't all countries in the European Union limiting the use of security cameras on public areas?