A public service is the task of proving service to a community or the citizens of a country. It includes all enterprises of public welfare and development.
The service rendered to military is an example of public service as military/army comes under the domain of public or governmental authority.
Therefore, serving in a military is similar to serving the public as it protects the people from internal or external challenges and unrest.