Military service
From Starport: Galactic Empires
Colonists may have their occupation set to Military Service. The amount of colonists in the military service profession will influence how fast the weapons factory produces weapons, if the weapons factory exists. The amount of colonists in military service also influences the fighting strength of Flak and Laser Cannons on that planet's surface, and the Solar Cannon if present. Specifically, the rate of bullet fire for each cannon is increased according to the number of colonists set to the military workforce, and each cannon's shielding is increased as well. To get an idea for the scale of this effect, a colony with 2,000 colonists in the military workforce (for example a colony of population 4,000 with military set to 50%) will about double each flak cannon's shields. The colony's military size will also make those cannons heal back to full strength faster, such as in 10 seconds instead of 30 seconds. The more colonists serving in the military, the better these effects are.
A military size of 5,000 (for example, a colony population of 20,000 set to 25% military) is sufficient to get the maximum military protection for a colony. More colonists than that in the military is superfluous. On a colony that has the Military Tradition research discovery, less colonists may need to be assigned to achieve maximum military strength.

