I don’t doubt people might be experiencing racist behaviour, but there also might be a legitimate explanation for much of this.
Schengen rules dictate that Schengen and other EU countries with freedom of movement get priority processing at Schengen borders. Passport holders of other countries are all second priority, including the UK now. The EU also agrees other policies with third countries. Ukraine has had visa-free access to the EU for a few years now, so I wouldn’t be surprised if they also were part of priority processing on the Poland-Ukraine border, or the current situation means a temporary arrangement has been agreed. This would also be the case for international trains between Ukraine and Poland.
I used to cross at Medyka-Shehyni frequently and when the UK was part of the EU, and Ukraine didn’t have visa-free access, I could get always get priority over all the Ukrainians at the Polish border points, but of course had to wait in line with everyone for the Ukrainian border checks. Checks for Ukrainians entering Poland at these times could be above 2-3 hours routinely unless you got there early.
As much as I have sympathy for anyone trying to flee from this, I would have fully anticipated Poland prioritising their own, EU and Ukrainian citizens in such circumstances. The EU isn’t just going to open the borders when people are relatively safe, albeit having a very long, uncomfortable, wait at the border.