But, if you go to Malta and live there more than 6 months per year, and work as a software engineer, you will have to work for a company based on Malta... unless the company you are working for has a branch in Malta or is using an intermediate company to hire you. Same for any other country in Europe. Many think that "Oh, I'll work for a German company earning German money while working from a beach in Portugal". Well, that's definitely possible, but the vast majority of German companies hiring remotely: a) do not have a branch in Portugal, and b) do not use intermediate companies to hire talent. So, more often than not, if you want to work from Portugal more than 6 months per year your pool of companies to apply for will be mostly Portuguese ones.
Also, even if you think "oh well, then I'll work from Germany 6 months and 1 day per year, and from Portugal the rest of the year", that may not work for some companies. Some companies, allow you to work from abroad (within the EU) but for a maximum of 3 months (becaues of health insurance issues).
All of this applies if you are an employee. For contractors, that's different.