Tickets for Intercidades (IC) and Alfa (A) are specific to a train, thay even come with your seat information.
Tickets for Regional (R) can be used in any train (in same day).
Both your options involve IC or A, so you cannot opt for another train after you buy your ticket.
My experience is that in these hours in working days trains usually have seats available until the departing hour, so if you can take some risks I would advise you to buy your ticket once you get to the train station (although queues may require you to be there 15m before timetable).
Credit:stackoverflow.com‘