Polish and Ukrainian economies were exactly the same size in 1991 after collapse of the Soviet Union.
In 2021 Polish economy was 3 times bigger than Ukrainian and almost 2 millions of Ukrainians emigrated to Poland for work.
Very clearly Poland done some things right, while Ukraine did not.
The one important thing that we have done right appears to be immediate turning towards West after collapsing communist regime in 1989. Joining NATO and EU.
Poland never wanted to be in the Russian sphere of influence. We have spilled rivers of blood in countless wars, uprisings and protests against Russian imperialism in past 300 years.
Ukraine means "borderland". Historically Ukraine was in a constant state of wars between Polish-Lithuanian Commonwealth, Swedish Empire and Russian Empire since before USA even existed.
So, historically Ukraine was always split between West and East. All regions of Ukraine very clearly wanted independence in 1991. But modern Western Ukraine wanted to join EU and follow Polish path to prosperity. That's why Maidan protests started in late 2013.
Putin invaded Ukraine because he believed in a false story that Ukrainians wanted to be Little-Russians fed to him by FSB agents (KGB successor). And in order to keep Ukrainians from the Western path to prosperity. Ukraine as prosperous as Poland, meaning more prosperous than Russia, would threaten his regime and Russian idea of greatness.
But Russian speaking Ukrainians sympathetic to Russia never asked for their whole lives to be upended and to be bombed by Russia into oblivion. Ukraine is no longer split. This war is their war of independence, true nation forming event. Their new found hatred towards Russia and Russians is enormous and that leaves them with the only other direction - towards West.