Dumbledore tells the Hogwarts students that once your name comes out of the Goblet, you're basically obliged to compete:
"Finally, I wish to impress upon any of you wishing to compete that this tournament is not to be entered into lightly. Once a champion has been selected by the Goblet of Fire, he or she is obliged to see the tournament through to the end. The placing of your name in the goblet constitutes a binding, magical contract. There can be no change of heart once you have become a champion. Please be very sure, therefore, that you are wholeheartedly prepared to play before you drop your name into the goblet." ("The Goblet of Fire")
Likewise, when Karkaroff threatens to pull Krum out of the tournament, Fake Moody basically tells him its impossible.
"Empty threat, Karkaroff," growled a voice from near the door. "You can't leave your champion now. He's got to compete. They've all got to compete. Binding magical contract, like Dumbledore said. Convenient, eh?" ("The Four Champions")
We never get a full explanation of exactly a "binding magical contract" works, or how Harry could be entered into one without his knowledge. But at the very least, three champions had voluntarily sworn to compete to compete in a Triwizard Tournament.
We're also never told what the punishment is for not fulfilling the contract. But we get two examples of "binding magically contracts in the books: The Dumbledore's Army list, which disfigures anyone who breaks their promise, and an Unbreakable Vow, which will kill you. Presumably, the effects of breaking a contract with the Goblet of Fire, a "very powerful magical object," is equally dire.
(It's also worth noting that Fake Moody's phrasing, namely that Karkaroff can't leave Krum, might imply that the headmasters are likewise bound to participate, in which case Dumbledore may have no choice.)