When economists talk about something being a "public good" they don't mean "nice stuff that the government does."
The definition of a public good is something that is non-rivalrous and non-excludable. Or in non-econogeek-speak, stuff that doesn't run out no matter how many people use it, and stuff that benefits everybody whether they pay for it or not.
National defense is a public good. I'm not saying all national militaries are "good" -- I think lots of militaries around the world are evil and the world would be a better place without them. But the idea of national defense is a public good-- assuming you're pretty happy with your government and don't want Foreign Invaders to take over your country, everybody benefits from a national military standing guard and keeping you safe. And assuming the Foreign Invader Threat doesn't grow as your population grows, the same military can protect 100 thousand people as easily as it can protect 100 million.
National defense is non-excludable and non-rivalrous.
One funny thing about public goods is since they're non-rivalrous, you can serve more and more people while spending the same amount of money. But we don't do that; we spend more and more money on the military. In all the debates about "cutting" military spending the most radical proposals still keep spending at some constant percentage of GDP.
Why?
We should be able to get the same level of safety from Foreign Invaders with a constant level of military spending, no matter how large our population or economy grows. We'd all be much better off, and much safer, if we cut military spending by 90% and spent the money on just about anything else.