Right, I should have cited the Roman Empire episode. ;D
I think that stuff about Gangsterland turning into Federationland was an idea for a followup episode (DS9 for the 30th anniversary) intended as a “tribute” to “trekkies”, with the aliens acting like Star Trek fans basically. They went with the tribble time travel episode idea instead.
Actually, there was a common thread running through some of the episodes, the Roman Empire planet and the one that had a mix of North American Indian tribes that was in the path of the asteroid, that an alien race called “The Preservers” would extract particular cultures of interest from planets that were likely to see them overrun or die out, and place them on uninhabited Class M worlds where they could continue to exist unmolested.
It was curious that in the case of the Roman planet, they extracted them right before Jesus Christ, but even in doing so, Christ still made His way there and would have a transformative effect on that planet. Imagine doing such a “Christian” episode today in SJW Faux Trekland (or yet another, presumably “Preserver” influenced world with the Chinese Communists and White Americans reduced to feral/tribal status with an unabashedly pro-American tilt to the episode with Iowan Kirk showing more respect for a ragged Old Glory than any leftist today).