I can see at least 3 factors that made Mexico increased their population slower than the US (from my personal perspective):
1. The fertility rate that the U.S population had in the 19th Century.
2. The relative
openness towards migration in the U.S compared to Mexico, especially when it came to the religious policy (de iure freedom of religion vs Catholicism as the state religion until the
Leyes de Reforma);
3. The stability, as you all say. The US was relatively a
stable country until the Civil War, meanwhile Mexico had several insurgencies and civil wars, along with an American Intervention and 2 French Interventions.
Now,
this article considers that, although the population increase in Mexico was
slow compared to the US, it was still steady and relatively
stable, ignoring the civil wars and epidemics that occurred. Some information is said about the question of the population growth:
In short, yes, the population growth in Mexico during the 19th Century could have been better if the constant civil wars and the foreign interventions never happened, but the population growth of the Mexican population was still slow but steady, to the point of going from 5 to 15 million people in one century.
Of course, an actual estimate of how many people died during the civil wars and the interventions can't be estimated since, for one, the administrative apparatus was basically a mess, and secondly, no official census was made until 1895.
This other document (in Spanish and it's a PDF that downloads automatically) considers that:
1. The biggest loses occurred during internally: The Casta War in Yucatán killed 5% of the population of Yucatán during the period 1840-1860, an aprox. number of 100 to 300k people that died or emigrated from the region. There are no estimates about who many people died during the American Intervention and the Reform War, but Robert McAaa considers that,
at least, 2.5 million people died if we mix all the civil wars and interventions until 1870, when the country finally started to pacify.
2. Ironically, the Mexican Cession didn't affect massively the population of Mexico, with a total of 113k people being in the Cession and Texas at the time the US won the Mexican-American War.
Supposing a
perfect scenario where Mexico avoids every civil war and conflict with a foreign nation but maintaining the same fertility rates and population increase (and excluding the foreign population becoming migrants, along with maintaining the same territories post-1848, that means, OTL), the Mexican population by 1910 should have around
22.5 million people. Certainly not too much, but better than OTL. Now, since a
perfect scenario doesn't exist, we should take into account if you want a Mexico that manages to maintain its Northern Territories from the US, or a OTL Mexico that loses the Mexican-American War, or a Mexico that manages to maintain the control over Central America.
You should also take into account the migratory policy that the Mexican state will use, how many stable is the country for an administrative apparatus to work properly, the improvement (or worsening) of the health system in the country, and the political stability (or not) that could avoid (or not) the civil wars that affected the country OTL.
My beast deal is that Mexico
can afford to reach 40 million people or more as long as it manages to control both the Northern Territories and Central America, and enforces a migratory policy that doesn't exclude non-catholics. That, along with a stable country that can afford industrialization and liberalization, will help to improve the quality of life and cause a baby boom for sure.