During the Texas War of Independence, Sam Houston pulled his refugees and army almost back to the Louisiana border, despite loud protests from many militiamen that wanted to fight.
Houston understood that every mile away from Mexico City undermined President Lopez de Santa Anna's political position, worsened his logistical problems, and further exhausted his men. Given the massacres at Bexar and Goliad, Houston believed Santa Anna was capable of more atrocities. If any occurred close to the US border, it might provoke an American intervention - and retreating east made it easier for American volunteers to join the Texan cause.
Houston strengthened his own army and political position by retreating, while making his opponent increasingly weak and rash.
Strategically?
Tactically, withdrawing to higher ground or more defensible position happens all the time.