short trips like pingxi to tms, no need to buy in advance. the frequency is very frequent, just buy on the spot. u can choose express or normal trains, reserved or non-reserved seats.
for longer distance eg hualien to/fro taipei, better to buy in advance as not as many express trains like puyuma. should have local trains if u dun mind the longer journey time.
best is to check the TRA website on the train schedules and frequencies.