The penalty payment only applied to the case that he couldn't secure funding.
To oversimplify it somewhat, he could back out and walk away owing the $1 billion only if his debt financing sources had refused to fund. It was unlikely that was going to happen because (1) his lenders had committed to finance the deal (barring the occurrence of very, very unusual circumstances) and (2) they had their own separate legal and reputational exposure if they didn’t show up at closing.
Courts didn't force this on him out of nowhere, he bought it then he wanted out when the tech market tanked, and courts just said no, you bought it.
He had a lot of time to back out with a penalty payment too and didn't do so.