Because soldiers serve the country they are a citizen of.
They thank members of the armed forces (soldiers, sailors, aviators etc.) for their service and most people extend these for the police force as well.