They don't at all. Consider for example that every single city, county and local council in the UK has a flag. There are flags for the United Nations, the European Union, Esperanto, every major football team and most political movements including the CND and anarchism.
“Nations” as synonym for country started appearing only recently, in last two/three hundred years.
Flags have thousands of years of history.