The major reason why there is a need for both of these forms of government is that most counties have a mix of towns and other areas. The typical county is not just made up of towns. It will also have rural areas. Those rural areas will still have some people, but those people will not be organized into towns. These areas are typically called “unincorporated” areas.
If we only had city governments, these unincorporated areas would have real problems. There would be no police protection or fire fighters for those areas because they are outside of the cities and towns. Clearly, this would not be ideal.
At the same time, it is necessary to have city governments. Most counties have multiple towns. The towns can be very different from one another and/or can be far away from one another. It would be possible to simply have one government for the whole county, but people in the towns would not really feel like they were in control of their own governments. There would have to be one government for all the towns and the people of some of the towns would end up feeling unhappy about not having their own governments.
For these reasons, both county and city governments are needed in most places. (There are some counties, like Honolulu County in Hawaii, that are so urbanized that they do not need both kinds of government. Honolulu’s city and county government are merged into one.)