The FRCA article on Wikipedia says:
“Independence proved short-lived, as local law and order broke down. Driven by regional rivalries, many localities refused to accept the newly formed federal powers in Guatemala—
San Salvador,
Comayagua,
León, and
Cartago were in open revolt. The ensuing anarchy prompted the land-owning wealthy and conservative class to advocate union with Mexico. On January 25, 1822 the Junta consultiva in Guatemala City voted for annexation. A few weeks later General
Vicente Filísola, the envoy of Emperor
Agustín de Iturbide of the
First Mexican Empire, arrived in Guatemala as the new ruler.
[4]
The annexation was controversial, with some seeing the Mexican constitution with its abolition of slavery and establishment of
free trade as an improvement over the
status quo. Central American
liberals in San Salvador objected to this[
clarification needed] and refused to accept Filísola's authority. The army[
which?] was ordered[
by whom?] to quell dissent. In the case of
Costa Rica, the country decided to join the Mexican Empire as part of the resolutions upon conclusion of the
Battle of Ochomogo (April 5, 1823), which is considered[
by whom?] the first civil war of
Costa Rica. After Iturbide abdicated (March 19, 1823), Mexico became a
republic(formally proclaimed on November 1, 1823) and offered the previously annexed Central American provinces the right to determine their own destiny. Filísola turned over his power to the hastily formed National Constituent Assembly, which comprised representatives from each of the five provinces. On July 1, 1823 the Congress of Central America declared absolute independence from Spain, Mexico, and any other foreign nation, and established a
republican system of government.
[4]”
So maybe you need to have Mexico just not offer them the option and try to keep a hold of them?