Traditionally, the teams played in the cities and carried the city names. But as stadiums moved to suburban areas, this created a problem. The first example that comes to mind is the 1966 move of the Los Angeles Angels to the Orange County suburb of Anaheim, which prompted a name change to California Angels.
In 1972, the old Washington Senators were lured to a rebuilt stadium in Arlington, Texas, a suburb halfway between archrivals Dallas and Ft. Worth. Naming the team after one or the other of those cities would annoy half the team's fans, and in any case the franchise had been lured by boosters of Arlington, not the older central cities.
As more teams moved to suburban facilities, the city name issue became less important, so the Dallas Cowboys now play at an Arlington facility less than a mile from the ball park the Rangers came to a quarter-century earlier.
More recently, new or relocating teams seem to have taken state or regional names—New England Patriots, Golden State Warriors, Carolina Panthers—as a way to broaden their fan base beyond those who feel loyalty to particular cities or even states.