would it make sense to set up multiple bank accounts to avoid going above their thresholds?
Quite possiblly yes but you need to pay attention to the fine print. I don't know what the situation is in poland but in the UK accounts that pay high interest often have strings attached. For example the santander 123 current account pays very good interest but it has an account fee and some other requirements that are difficult to meet if you are not using it as your "main current account".
You need to read the terms carefully, if you go over the threshold does the lower rate only apply to money over the threshold? or does it apply to all the money in the account? Are there any other restrictions on how you use the account.
Also I don't know if poland has any provisions for limited tax-advantaged savings (like the ISA scheme we have in the UK). If it does then that can add further complications.
How to calculate how to maximize the profit here?
Well in theory you would get the best account you can and fill it to the threshold. Then the next best account and so-on. You would move any interest paid in an account that was already full to the threshold to the best non-full account (or if the account strongly peanalises going over perhaps move an ammount of money equivilent to the interest just before the interest is paid).
In practice that is a lot of work, so if the rates on the different accounts are similar you may want to leave some margin for interest or (in the case of an account that pays the lower rate on the overage while still paying the higher rate on money below the threshold) accepting that some of your money will earn slightly less than idea.
Another option some accounts may offer is just to pay the interest to another account, avoiding the need to move it yourself.
Finally you should check out your government's limits for compensation in the event of banks going bust. As a general rule you don't want to put more than that ammount in a single bank even if doing so would get you the best interest.
I wonder how compound interest interacts with this one
Why is this a problem at all to calculate ?