Technically you are correct, Yorgo, it is not necessary to have a law but having a law does have an effect.
Everybody knows how the virus spreads. It is expelled in water droplets of varying sizes on the breath of infected people. It may then be breathed in by uninfected people close to them or it may deposit on surfaces which uninfected people might touch and indirectly infect themselves.
Knowing the infection mechanism means that the methods of avoiding infection are obvious. Wear a mask in case you are infected so anything you breath out mostly gets trapped in the mask. Don't get too close to other people, the further away the better. Wash your hands thoroughly and regularly, especially after touching any surface that might have become infected.
Everybody knows these "facts" and every country has done its best, some better than others, to inform its citizens of them. Some countries have used strict laws to force its citizens to obey these rules and some haven't. Norway and Sweden are two good examples. They are neighbouring countries with similar cultures, climates and population densities, although Sweden has about double the total number of citizens than Norway. Norway went down the strict legal route of enforcement. Sweden went down a very relaxed legal route relying more on people voluntarily obeying the rules. So far Norway has suffered 142 deaths per million population while for Sweden it is 1,406, i.e. ten times the death rate. Those are real "facts".
Around the world the countries that have the lowest death rates are those that have had rigorous legal enforcement and the ones with the highest death rates are those that didn't. Interestingly right at the beginning of the pandemic the WHO advised that the only way to stop the virus was to test, trace and isolate. The countries that followed that advice rigorously are the ones with the absolute lowest death rate and today have the most open economies. The ones that didn't follow that advice have the highest death rates and have suffered the most economically as well due to lockdowns.
Those are real "facts" backed up by published, hard scientific data.