In Poland you are a tax citizen automatically if you have been there more than 183 days[1]. The exact same 183 in Portugal[2]. It is an automatic thing so quite simple.
I beg to differ. Those look like the "default" rules. For the example of Poland (picked one of your two examples) it's not so simple.
The "default" rules for tax residency are superseded by a convention between the two countries, and there are a bunch of them, with many countries, on the site of the French government. There are specific conventions with Germany, Belgium and Switzerland, for example, that apply only to people living close to the border and working in the other country. If you take the train from Paris to work in Geneva, it doesn't apply.
Basically, it can be debated. It says that if you have a "permanent home" in both countries, you're a resident of the country "with which you have the most attachments". So for the hypothetical Polish worker who's "detached" in France, it could be argued that the "attachment" is to Poland, because their family is likely there, among other things. In the case of a freelance moving from country to country, who is likely unattached, this can probably be easily argued (though I'm not a lawyer).
Concerning remote-working freelance: For "independent workers", you're taxed in the country where you do business, except if you have a "fixed base" in the other country, from which you conduct your business. In that case, you're taxed in the country where the base is, but only for the part of income that is attributable to the work done from that base.
[1] https://taxsummaries.pwc.com/poland/individual/residence [2] https://taxsummaries.pwc.com/portugal/individual/residence