A common phrase regarding US cities is, "cities are creatures of the state." All of their authority comes from the authority granted states, and states can limit the authority of cities, counties and their other political subdivisions. In the US cities cannot have additional authority beyond the authority the containing state has, as opposed to, for example, cities granted Royal Charter in the United Kingdom, which may have equal or greater authority than their containing counties.
Most states have constitutional and legal descriptions of what powers cities and towns can exercise. Recently many cities have begun passing laws to ban things like plastic grocery bags or hydraulic fracturing, and states have then passed laws to remove that authority from cities.
States also set requirements for creating new towns. In Texas, any town smaller than 5,000 population is a general law town. General law towns have very little authority to create laws, but they can have a police force to enforce state laws. A city in Texas with population larger than 5,000 people can enact a charter by popular vote and become a home rule city. Home rule cities in Texas can enact some laws with criminal punishments (only citations and class C misdemeanors) and have greater taxing authority, but really can only pick from a menu of options created by the state.