It was part of the mostly unsettled territory claimed by Spain. After Mexico became independent from Spain, it was so incompetently ruled, it could not hang onto it's northern territory for more than 25 years. Arizona was part of Mexico for a very short time. Less time than Mexico was part of France I believe.
I posted the history of the State of Arizona as posted on a State of Arizona website.
It belonged to Mexico, now all you guys are busy excusing off people taking land that doesn't belong to them.