Because citizenship is a commitment, not merely a set of privileges. If you obtain a citizenship (or have it imposed on you upon birth), it comes with a set of duties other residents and visitors do not have. The duty to defend your country is a traditional one.
Some countries may conscript non-citizens or allow them to serve voluntarily. Often because they are more likely to use the military as an extension of foreign policy rather than for defense. Others may see it a waste of effort, as those people are probably not sufficiently committed to the continued existence of the country.