What is a city-state? There are no city-states left in Greece to use as an example. We have to look into the past to find some.
After the Greek dark ages, villages started to band together, in part for protection and in part for more organized trade. They wanted strong trading centers. These groups of villages were that banded together were called city-states. There were hundreds of city-states in ancient Greece, some small and some really big ones with large populations.
Although each city-state had its own form of government and its own army, sometimes its own navy, and certainly its own way of doing things, the city-states of ancient Greece had many things in common. They all spoke the same language, they all believed in the same gods, they all worshiped in the same way, and they all thought of themselves as Greeks. But they were loyal to their city-state. If you asked someone in ancient Greece where they were from, they would not say they were from Greece, because Greece at that time was not a country. It was a collection of city-states, each with its own personality and way of doing things.
The city-states banded together to fight outsiders. They also banded together to fight each other.