Yes. Without restriction, without any special permit. This is the most common worry, and the one cleared up fastest.
There were once restrictions that tied property ownership to a Swedish place of residence. Those days are over: since the year 2000, anyone can buy a property in Sweden, regardless of nationality or residence. As a foreigner you have the same rights as a Swede.
As an EU citizen you also need no residence permit even if you stay in Sweden longer than three months. Free movement within the EU applies here too.
These are often mixed up. You can own a house in Sweden without living there: as a holiday home or as a project for later. The purchase itself requires no move.
If you want to move to Sweden permanently, further steps follow: registering with the tax authority Skatteverket, and the personal number (personnummer) that opens up everyday life, from a bank account to a visit to the doctor. That is a separate topic and no obstacle to buying a house. It comes after, not before.
Legally, the purchase is straightforward for foreign buyers. What actually holds people back is something else: the unfamiliar language, a process without a notary that feels unusual, and the worry of ending up with an unfair seller. That is why it is worth having someone alongside you who speaks the language and knows the market from the inside.