The situation is similar in Germany (and used to be much more common). With any train that does not operate as a fixed unit (think ICE in Germany or Pendolinos in the Czech Republic) carriage numbering can and will often be arbitrary. Sometimes there is still a residual meaning visible in carriage numbers but often enough there is no apparant one.
My suspicion is that this is inherited from former times. Back in the olden days where multiple units were rare (and exceedingly rare for long-distance trains), it would have probably made sense to have a unique organising scheme among carriages of a train pair. So for example, one train pair departing from hub A would run with carriages 1 though 10, the next would take 11 to 17 and so on. These train pairs would then not simply run from hub A to hub B and back but rather A to B, B to C, C to A, A to D, D to B … over the course of a fixed number of days before they ‘return home’ for inspection. Of course, these itineraries would be modified every two years or so.
Of course, the olden days were very happy with using through coaches. So suddenly carriages 16 and 17 no longer followed 11 through 15 on their initial route but went together with 39 through 45 somewhere completely different. And that too would change every few years.
When changing, maybe efforts were made to ‘preserve’ the car numbering for certain important legs of the itinerary, leading to entirely jumbled-together numbers; neither ascending nor descending nor continuous. And this is where we are now.
Carriage numbers need only be unique within a train (you can’t have two carriages numbered 17 in one train, obviously). But very typically, they will be identical for both the outwards and return legs. The main difficulty, and why not everything is simply numbered 1 to whatever is when through carriages change trains and need to fit in to more than one numbering set. The train your picture shows is a night train and seems to be split up into at least five parts (Krakow, Bohumín, Kiev, Poprad-Tatry and the main destination).
Note, by the way, that those carriages going in the same direction are both contiguous and either in ascending or descending order, so it is not as random as it may look.
To find your carriage in a certain train you cannot rely on always-working hacks. Most of the time, at least for larger stations, there should be a poster of some sort displaying which trains depart from a given platform and what the order of carriages will be. Every now and again, though, stuff happens and the carriage order changes. (E.g. the train from Kiev on the reverse journey may be late and the car added after those to Poprad — assuming they get added to that train in the same station.) If you happen to be at the wrong end of the platform, in my observation it is typically faster to move along the outside of the train rather than board at the wrong end and make your way through. However, pay attention to the departure; you don’t want to be caught outside of your departing train.
: For example, the now discontinued night train route from Munich to Hamburg and Berlin (only remotely related to the Munich–Hamburg night train still running but to be discontinued in December) had carriages 11 through 15 for the Berlin coaches and 21 through 32 or so for Hamburg.
: A train that goes to X typically also comes back from there at some point. These are typically two trains with adjacent train numbers, one even one odd. And it entirely makes sense for one to run exactly in the reverse direction of the other.