Not that rare in California. Off the top of my head: Sonoma, Napa, Mendocino, Santa Clara, San Mateo, Santa Cruz, Monterey, San Diego, San Bernardino, and Alameda counties all have cities of the same name. Seems rare in most other states though.
It is rare in most states, I believe. It is very common in South Carolina (see https://en.wikipedia.org/wiki/List_of_counties_in_South_Caro...), which has counties named things like "Greenville" and "Spartanburg" after their largest cities - it feels to me like those should be "Green" and "Spartan". And then there are states like Georgia where there are counties, and cities with the same name that are in different counties, because the county-namers and the city-namers were pulling their names from the same pool of well-known people but weren't talking to each other.
Also, in California: San Luis Obispo, Riverside, Sacramento, Fresno, Santa Barbara.