The IOC has actually had to backtrack quite a few times at much later points in the process than host selection, 8 years out.
The 1904 Olympics in St Louis and 1908 Olympics in London both were originally set to be staged in different cities and apparently moved within about 2 years of the games.
Now, obviously those were a different era in the scale and spectacle of the Olympics. And there's also not great information out there on how early St Louis/London showed interest...
But there's a lot of information on the mess that was the bidding for the 1976 Winter Olympics.
4 countries entered the final round of bids in 1970:
- Denver, US
- Sion, Switzerland
- Tampere, Finland
- Vancouver, Canada
Then withdrew 39 months before the game after voters blocked funding.
Then Whistler, near Vancouver, was selected. They turned it down due to a government change.
Then the US suggested Salt Lake City as a replacement. SLC withdrew their offer due to economics.
Then the US suggested Lake Placid.
Finally the IOC opted to put it in Innsbruck, Austria just 36 months before the games. Austria had not bid previously.
But that gives a suggestion as to what would happen if everyone withdrew (or if something came up that would prevent hosting): a recent host would end up with the games. They have the infrastructure, they have the experience, and they would need less preparation time. It would seem a straightforward fit. (Innsbruck had held the Winter Games 12 years earlier)
Similar has happened in the World Cup, when in 1982 Colombia withdrew from hosting the 1986 World Cup after being the only country to have put in a bid. A new bidding round was requested and three countries made entries; Mexico, which had hosted 16 years prior, was unanimously selected.
A more recent extreme example is the 2015 Africa Cup of Nations. Morocco and South Africa made bids. Morocco won. Then Morocco apparently withdrew just THREE month before the tournament over fears from the Ebola outbreak. 2012 co-hosts Equatorial Guinea took it on, even in a climate where many others refused to consider it.
So it would seem likely that there would be some combination of a rebid round or private negotiations, and that it would likely end up moving back to a recent host.
And if no one still was interested?
Well, the IOC could pay to hold the events themselves, without any direct assistance from the cities. Smaller sporting events do this all the time.
Or they could cancel.
But doubt we'll come to that any time soon, even with the economic benefits of hosting being uncertain. The Olympics are a huge world event, with plenty of attention and fame. Someone will do it.
(You can see the entire history of Olympic bids on Wikipedia)