Very rarely is a particular airframe used as the spare. A schedule is however built to maximize the degrees of flexibility as to which particular airframe can be used for any particular flight. eg. If you have 3 planes each flying 8 hours a day, you theoretically can schedule them so that there are 2 planes backing up the third plane at all times (in practical terms however you will almost certainly have less, especially in a hub-and-spoke model).
There are other variables of course such as scheduled maintenance downtimes, parts and labour availability, etc.. but there is an entire science of scheduling which works to accommodate these and optimize utility within a set of constraints while still maximizing the operational flexibility.