Crossing the border between Malaysia and Thailand, or vice versa, when you are catching the train involves alighting at Padang Besar station. Then you carry out the formalities. You exit one country and then enter the other. And then you get on a different train towards your destination.
There is essentially one station, with a Malaysian and a Thai part, and with the same name. There is a town on both sides of the border. They are both also called Padang Besar. For more photos and details about the train journeys see The train from Malaysia to Chiang Mai.
Crossing the border between Malaysia and Thailand
Signage is not good, but to go on to Thailand you just walk along the platform in the direction of Thailand. That is, in the direction the train was travelling. Of course, photographing the actual immigration booths is forbidden.