Presumably they’d get bulk of their money back if it were cancelled. But in turn they’d have to pay the BBC and anyone who they’ve sub licensed rights too.
2020 rights (now 2021 rights) are with the BBC and sublicensed to Discovery.
Rights up to and including 2020 were purchased by the BBC just before the 2012 Olympics.
Discovery has the UK 2022 and 2024 rights, sublicensed to the BBC, in return for being able to show the 2018 and 2020(1) events.
That's just for the UK - they're prime rightsholders in many other territories.
I would imagine the IOC have some pennies in the kitty to reimburse all rightsholders in the event of a cancellation, though there are obviously some sunk costs on technology that won't be able to be used until 2022.