Well, the transpoder or squawk codes are assigned by the ATC or by the control software, in the case of Mexico, the leading software is the Eurocat X
For this porpouse the criteria is based on the ICAO regulations where qre stablished the emergency and dedicated codes.
For emergency, the discrete codes are:
7500 - Hijacked
7600 - Radio/Communications Failure
7700 - Emergency
Also the dedicated, basic codes are:
1200 - For VFR Flights with unassigned code and below 12000 ft
1400 - VFR flights over 12000 ft
1500 - Helicopter on VFR Rules
2000 - IFR flight with unassigned code
The rest of the assigned codes are based on a destination and airpace criteria, for example if the aircraft destination is international, regional, national, intercontinental, etc.
And the idea is to never repeat a squawk code on the same area in order to have the accurate information of the flight and airplane.