@Ann *************
Firstly, there are trains that cross the border into Malaysia anymore.
Secondly, the only international train service that is currently running, which is from Nong Khai to Thanaleng (Vientiane) in Laos, doesn't offer a way of buying tickets in advance. You have to purchase them on the spot.
This may change once the new Khamsavath station opens, from which there will reportedly be trains running all the way to Bangkok (and vice versa of course).
However there are cross border buses from Thailand to Cambodia and from Thailand to Laos. If you can somehow secure an advance booking on one of these, perhaps that would satisfy immigration (in the unlikely event they would even ask). The airline could insist on an outbound flight ticket but some have been known to accept Confirmed bus or train tickets (as mentioned, only bus services are currently offered).