the US Army can cook food, provide medical care, transport goods and people across the world, engage in large construction project, conduct law enforcement operations, provide maintenance for a wide variety of a équipement and structures, provide electrical power, etc. all things that can be done by other organizations. what does other organizations can't do however, is provide national defense.
Starfleet provides national defense. no matter what else they do since they fight the wars, they are military.