It’s not so much a mechanism that allows such a thing. It is rather that there is no mechanism that forbids such a ridiculous thing. The US Constitution only lists age, residency, and citizenship requirements.
Donald Trump’s antics and disregard for norms and laws have made us think about things that the founders never imagined. They were bright, educated guys who understood politics and human nature. They knew about entitled classes and the “divine rights” of kings. They likely understood narcissism, even if they didn’t have a name for it. They understood corruption and the seductiveness of money and power.
But they never saw this guy coming.