Are airport terminals defined when flights are initially scheduled, or airlines/airports change them and/or make them available to passengers as flight departure approaches? (similar to gate numbers)
An airline at a particular airport usually has facilities in only one terminal. This includes check in desks (with all the required computer connections), baggage handler contracts, as well as signage and other paraphernalia. In a few cases, an airline may have facilities in two or more terminals, particularly if it has a very large operation at that airport.
At some airports the terminals can be miles apart, and some terminals can only handle certain kinds of flights (for instance, only international or domestic, or perhaps only flights to/from certain destinations for security reasons, or some terminals may be unable to cope with very large or very small aircraft). Moving terminals can cause significant confusion to passengers and can interfere with the minimum connection times for already-booked itineraries. Therefore moving terminals is not undertaken lightly.
Gates on the other hand; at some airports gates are reserved to certain airlines, at other airports, they are not much different to parking spots; whoever lands there first can have the gate.
Highly dependent on airport configuration. There was a period when Southwest Airlines at OAK used both some gates at Terminal One and all of Terminal Two. They are a 5 minute walk apart, and connected by an airside passage. It seemed to be no less common to change from one terminal to another as an ordinary gate change.
Southwest no longer has any gates at Terminal One, so this no longer happens.
My knowledge of different airports is not exactly vast and all I know stuff about are in Europe, but there is a pattern nonetheless. Often, if an airport has two different terminals (as in actually physically separated buildings; I am somewhat hesitant to use Helsinki airport’s ‘terminals’ in this context), they will have been built at different times in the airport’s history. This will also mean that the second terminal was added later to accomodate for a larger number of flights, and if you’re going to separate flights by terminals you may as well do it properly, i.e. in an organised manner.
That is why often one terminal handles all the flights of one alliance while a second terminal handles all the other flights — the terminal handling just one alliance (plus maybe minor non-alliance flights) typically handles the respective country’s flag carrier and is often the newer terminal (e.g. Munich, Heathrow). Frankfurt airport is the most notable exception where Lufthansa’s (Germany’s flag carrier’s) and thus Star Alliance’s flights depart from the older terminal 1.
As others have mentioned, there are a lot of physically hard-to-move facilities in terminals that airlines rely on; check-in desks being one of the most visible. But also, staff is required that often has to move between gates after one flight has departed to take care of the next flight. Having the staff move from one terminal to another would be a major hassle if it is just for a flight or two. Of course, if an airline uses more than one terminal anyway, this is less of an issue: just hire terminal-specific staff.
And this is where I’ll bring in Helsinki after all: while Finnair flights typically arrive and depart from terminal 2, the two terminals are the same building and merely separated by a hallway. If for some reason (accident or whatnot) too many gates on one side of the hallway are blocked, I can easily see Finnair diverting a flight to a terminal 1-gate close to terminal 2. In this case, the hassle of moving would be less than if you had to go from one far end of Munich’s terminal 2 to the other.
Of course, unforseen major catastrophes may always happen. If there are resources available, the lesser hassle would sometimes be to direct passengers to a different terminal rather than cancel their flight altogether.
Tl;dr: switching terminals, especially when terminals are separate buildings, isn’t done in a minute. Thus, terminal changes for flights are rare but can happen.
They are more likely if the ‘terminals’ are within the same building or if the airline departs from both terminals anyway.