Nope, not at all.
Spain owned Mexico? Okay, Mexico is the Aztec Empire which never ever extended close to our present borders let alone into the Apache, Navajo, or Pueblo nations.
Spain lost control of it's territories when Napolean invaded Spain.
In the Spanish territory of the Aztec Nation a Spanish general declared himself the leader of the Aztec Empire which is central southern Mexico. At the same time the Spanish general who deserted declared the Spanish territories his.
Mexico never extended past the boundary of the Aztec Empire. Mexico was always central mexico and farther south. Mexico is the word the Aztecs used to describe themselves.
Yes, Spain lost its territories because of Napolean invading Spain.
Yes a Spanish general left the Spanish army and declared the Spanish territories would remain his.