Did Central America ever belong to Mexico?

Yes. By 1821, the New Spain's territories included most of the US Southwest, present-day Mexico and most of Central America (Guatemala, Honduras, Nicaragua, El Salvador, Costa Rica); the Philippines were also administered from New Spain. Belize was known as the British Honduras and Panama was part of the Captaincy General of Venezuela.

When Mexico won its independence war in 1821, Central America also briefly was part of the new country. It however, split apart bloodlessly in 1823 conforming the Federal Republic of Central America.