The risk is present (although not necessarily strictly equivalent) but it has to be balanced against other concerns:
The right for everybody to enter their own country. Some countries have effectively stopped the return of their own citizens by curtailing air traffic but it would be legally, politically and diplomatically highly problematic to flatly deny them entry, certainly in Western Europe. In spite of their long association (historically and then through the Nordic Council and the EU), Denmark doesn't have the same concern with respect to Swedish citizens.
What other countries have done is impose some sort of mandatory quarantine or other restrictive measure to strongly disincentivize (leisure) trips abroad while formally safeguarding citizens' rights to return home. Some islands (New Zealand but also French overseas territories) even paid for accommodation during this quarantine period as another compromise between supporting the right to come back home and public health restrictions.
The right for everybody to come and go as they please. Outside of a temporary lock-down or individual measures (e.g. for people under criminal investigation), blocking people from leaving is associated with police states like the former East Germany. Denmark has announced some time ago that they were coming out of lock-down and presumably does not want to arbitrarily restrict its citizens' freedom any longer. Western Europeans obviously feel no compunction about blocking people from entering so there is no mirror concern about restricting Swedish (let alone non-EU) citizens freedom of movement in Denmark.
Generally speaking, it also seems clear that during the Covid-19 pandemic, European countries have prioritized domestic concerns and constituencies over anything else, perhaps to a larger extent than expected by some observers. This might stem from a feeling of distrust and lack of control on policies in neighboring countries, from a sense of national belonging during a crisis or even from a disregard for “other” people's needs and feelings. Thus, you are currently seeing countries allowing restaurants or hairdressers to reopen, large movements between regions, etc. all the while making it impossible for family members to see each other across borders, which doesn't necessarily make sense from a pure risk management or global welfare perspective. Denmark focusing exclusively on its own citizens rights and wishes fits this pattern.