they have certain requirements above and beyond the normal "commercial off the shelf" (COTS) capabilities. Say they want 99.9999% reliability, and they define how to measure that reliability. They define a bunch of other requirements (maybe bullet weight, shape, powder type and charge). They might have a preference about the type of action and minimum round capacity, the preferred materials the weapon is allowed in certians parts, the ability to fire the weapon with heavy winter gloves on, etc.
Manufactuers either offer a weapon they already have, or design or modify a new gun to meet the military specifications that they have defined.