By default train tickets are not for a specific time, but are for a specific date. Tickets are for a route, not a train.
So even though you start the purchasing process buy selecting from a schedule that does not mean that you are bound by that schedule. It depends on the type of ticket you buy. Generally speaking there are up to three options that you will see:
= Standard "point to point" ticket. This ticket allows you to take any train on the route on the date you selected. The price is always the same, wether you buy it a year or a minute beforehand, so the only reason to buy that in advance is for convenience.
- Supersaver tickets: Discounted tickets that limit you to a particular departure. They are a fairly new thing. Tickets that limited what train you could take were until recently completely unheard of in Switzerland. Do not buy this if arriving by air, as a delayed flight indeed means that your ticket is useless.
- Saver Day Pass. Gives you unlimited travel on all public transit in Switzerland. Will be offered if a SDP for your selected day is available at a price lower than the standard ticket. This is a good choice when arriving by air, as it is fully flexible.
Note: You can buy a ticket Basel Euroairport - Martigny. There is no need for separate tickets for the bus and the train.