I don't think television stations have ever been required to have actual facilities in their community of license. The requirement is to provide what used to be called a "Grade A" signal to the community of license, which gives a decent amount of flexibility for placing a tower.
For example, WTWO is licensed to Terre Haute, Indiana. But their studio and transmission facility has been based in nearby Farmersburg since its sign on in the 1960s.
EDIT: And as far as how cities are selected for stations to license in: Back in the old days, a bureaucrat at the FCC would publish a list of channels and communities which could be authorized to have television stations. Then would-be broadcasters would apply to operate those facilities. As an example, Jacksonville Illinois was granted an allocation for channel 14. Jacksonville was a fairly small city, having a population of about 20,000 in 1960. It is located roughly halfway between two larger cities, Springfield and Quincy. A group of entrepreneurs from Jacksonville decided it would be possible to serve Jacksonville, Springfield, and Quincy from one tower site. They built a tower of 1600 feet and received a 5MW license from the FCC. And failed almost immediately, as many UHF stations still struggled in that era. Channel 14 in Jacksonville would broadcast for barely two years before going bankrupt.
Many stations are still on the air, licensed to smaller communities within a market area. For example WTTV was a long-time WB/CW affiliate until earning the CBS affiliation a few years ago. Also in Indianapolis, the MyNet affiliate, WNDY is licensed to Marion, Indiana.
With the digital and channel sharing changes, the rules have gotten a little murky, so decode all of this with a 1990s perspective.