State pension is only paid for residents of the state.
Untrue. Poland pays out from the very first contribution, regardless of where the person is resident. If you work 10 years in Poland, then you'll get a pension based on those contributions (which depends according to the amount contributed, rather than a fixed rate amount).
The difference is that in EU countries (and with other ones where Poland has signed an agreement), you can transfer the contributions. For instance, if you have contributed 100,000zł in PL, you can transfer that to another system as long as Poland has an agreement with that system.