I know you have more than one thread, so this post does not completely describe your plans. But we have found, on multiple trips to Germany, that it was difficult to integrate Poland into the trip, even with substantial advance planning. It's also not clear if you mean a train journey as last-minute stops in places where you have no hotel reservation. I personally would not do that. As I may have written before, August is peak European vacation time, and I would also not want to risk being stuck in a hotel without air conditioning in August.
As a halfway measure, you might consider flying from your last Poland city to Cologne, because it is so well-connected to Brussels. But it is fair to say that there is even more to do in Berlin than there is in Cologne. Easier flying plan, you could fly to Frankfurt to take the dayboat on the Rhine (say, from Bingen to St. Goar), and then train to Cologne. But it will be a crowded boat, that I would not do with luggage in August.
https://community.ricksteves.com/travel-forum/germany/can-i-see-enough-of-cologne
If you don't care to read all of my trip report, you might use a search tool to find the sentences that report on the "train" segments in Poland:
https://community.ricksteves.com/travel-forum/trip-reports/four-cities-in-poland-2019
I have not researched the actual rail connections, but it might make more sense to train to Germany from Wroclaw?