It is one of the biggest mysteries in Mexican history, from what I understand it boils down to a few things:
- He had the army on his side; he was "one of the boys" and was liked and respected by most (keyword "most") officers. So when the need arose the army would rally behind him, this gave him a leg up against any politician since he could easily stage a military coup.
- He was able to keep the army politically "neutral" while personally flip-flopping between liberal and conservative factions. So he always appeared to be a good compromise candidate. Santa Ana also abandoned the Presidency as soon as he could so it is likely most saw his appointment as a "temporary" measure to stabilize the country between elections. And with the exception of his last tenure, this mostly was true.
- He was king in Veracruz. Even when he wasn't President, Santa Ana had a strong grip over his native land. From his estate, in Xalapa, he had control over Mexico's main port to the outside world and the national highway leading to the capital.
- Finally, he was able to foment a patriotic image around him as a hero of the War of Independence, the ousting of Agustin de Iturbide, and the defender of Veracruz against the French. I reckon that for most of the peasantry Texas was too far away and not really an issue, meanwhile, the French in Veracruz seemed like a much more dire threat. And Santa Ana "sacrificed" his leg for the motherland!