Engines sometimes need to be changed for various reasons, such as internal problems such as failed bearings or metal shavings from a failed component, or due to birdstrike damage, or other reasons. When the determination is made that an engine needs changing, the aircraft may not necessarily be at a location where the airline involved has a spare engine and folks to change it.
Three- and four-engined aircraft can ferry (sans passengers) to locations where the engine can be changed. This is usually done with a management crew flown in especially for the flight. Such a ferry usually isn't a problem, but sometimes they crop up. An ATI DC-8 freighter taking off from KMCI a few years ago on a three-engine ferry aborted takeoff, taxied back and tried again, only to crash on the second attempt. Back in the 1980s sometime, an Eastern L-1011 on a 2-engine ferry coming out of Mexico City to KMIA lost another engine on departure, and they returned safely to MMMX on a single engine. Those are the exceptions; most go off without a hitch.
With two-engined aircraft, the engine must come to wherever the aircraft happens to be, and changed on-site. Here in the US, that means that you usually truck-in a new engine (which can take a day or two, depending how far the aircraft and replacement engine are from one another). In some other cases (with larger engines, or at remote places) a new engine has to be flown in either a dedicated cargo plane, or ferried in as an "extra" engine on a scheduled flight. There a number of photos of 747s and DC-10s in the database that show an extra engine hanging on the wing.
Hope this helps...
ALL views, opinions expressed are mine ONLY and are NOT representative of those shared by Southwest Airlines Co.