After Moctezuma was taken hostage, he apparently developed Stockholm syndrome, and came to have a real fondness and even dependence upon Cortés. The conquistador was known to have had a Mansonesque personal magnetism about him and often managed to convert captured enemies into his most loyal followers. He had a way of playing the savior who would rescue prisoners from the cruelty of his own men and restore them a portion of their former dignity. It worked on Spanish and Indigenous alike.
But how the &%$#! did the most feared man to walk the Earth allow himself to be cowed and taken prisoner so easily? Aztec emperors weren't effete hereditary monarchs, but mentally and physically tough elites chosen by a council of high nobles. Before the arrival of Cortés, his reign could be viewed quite favorably compared to his predecessors. And after Moctezuma the Mexicans fought nearly to the last man.
The only thing I can think of is that Moctezuma was so accustomed to being feared as a demi-god that he was thrown off his game by a man who wasn't intimidated by him. The Aztecs maintained control through terrifying, showy displays of power. Cortes' audacity and sangfroid may have caused him to lose his nerve, and the Spaniard (a skilled manipulator) could read it in him even before they met in person.
Once Moctezuma's own subjects were fed up enough to stone him to death themselves the Mexican defense began in earnest. They adapted themselves quite well considering the rigidity of their society, but Cortés was a wily opponent. Once the aura of Tenochtitlan's invincibility was shattered, old enemies came out of the woodwork in droves to assist the Spanish. An epidemic that killed one out of every two Indians but left the Spanish untouched didn't help much either.
Another huge factor was that for Mesoamericans war was a religious spectacle, conducted in close consultation with ritual calenders and involving a lot of costumes, music and dancing. For the Spanish it was war-war, where you kill as many people however easiest you can do it. This book made a fairly good argument for the idea that the Aztecs suffered terribly for their stubborn insistence on trying to capture the Spanish alive for later sacrifice. It's hard to prove, but how else could the Spanish (often wearing cotton armor) have mowed through ranks of soldiers trained from birth so easily? Cortés himself was captured alive no less than 3 times, but each time another Spaniard waded through the thick of battle and freed him. Surely if they had not acted in the manner of the Penguin upon capturing Batman, they would've stopped the Spanish cold. But that wasn't how the Aztecs rolled; Tenochtitlan's final stand against foreign barbarians was not the time to displease their gods. Perhaps given the extraordinary threat of Cortés, it was all the more important that he be captured alive, that he be forced to dance for hours holding a paper flag, that he have his heart cut out by the high priest of Huitzilopochli, that his corpse fall bouncing down the steps of the Templo Mayor, and that the victors divide up his body for use in ritual cannibalism.
Cortés did die in Spain a broken man, his achievements forgotten and the empire he conquered governed by pencil pushing bureaucrats. The conquistador's conquistador met the most ignoble demise an adventuring mercenary could face, just as Moctezuma (heckled and stoned by the masses once forbidden to meet his gaze) suffered the most shameful imaginable end for a god-king.