So if I want to buy the international ticket from Krakow to Bohumin, I would buy that one at the station in Poland?
Yep, anyway it's full fare, thus no need to buy it in advance since the price is always the same anyway.
What if I wanted to go to Budapest instead? are there any tricks to go that route?
There are, but it will be a bit more complicated to get a good total price. Easiest will be same Krakow-Bohumin (16 EUR), then bought in Bohumin ticket till Budapest, which won't be cheap (50 EUR). That way you save around 15 EUR comparing to the direct Krakow-Budapest full fare one-way ticket (81 EUR). More complicated (and time consuming) way is go with combination of tickets Krakow-Bohumin (16 EUR), after buy Bohumin-Sturovo (app. 27 EUR), then get off train there, cross the Danube and board domestic Hungarian train Ezstergom-Budapest (app. 3.5 EUR). As you can see it might not seem like a great option, that is why in the first post we suggested to stop in Bratislava first (thus to do Krakow-Bratislava) and only afterward do a side trip to Budapest.
Also some days of the week there are overnight bus from Krakow to Budapest, it isn't a train, but no hassle and relatively cheap comparing to rail tickets.
Is it possible to just buy most tickets at the station or is that a big risk for us to end up paying a lot of money?
We don't really know what you mean by "a lot of money", but let's just list it (all of the below are fares you'll pay if purchasing before departure at the station): Krakow-Budapest cost 81 EUR (+reservation), Budapest-Vienna (25 EUR), Vienna-Bratislava return (14 EUR), Vienna-Prague (60.4 EUR + reservation), Prague-Munich (57 EUR) and Munich-Zurich (75.2 EUR). While purchased in advance discounted tickets can roughly save you more than half of the total.
p.s. regarding Krakow-Budapest we also advise you just to search our forum. Questions about this route arise pretty often, so maybe you can read some old suggestions and it can help you think of a best option for you