Most squawk codes are randomly assigned and change when the plane is handed off from one controller to another.
A few are reserved for specific reasons.
1200 - Flying visual flight rules (VFR)
7500 - Hijacking
7600 - Lost radio/communications
7700 - General Emergency (Engine Failure, Medical Emergencies, etc)
Others are assigned reserved for specific reasons - search and rescue etc.