NPCs in Terraria have different likes and preferences. Some of them have specific preferences for terrain and neighbors. Merchants, zoologists and guides usually choose to open shops and trade in the forest. Witch doctors and nurses like Hallowed ground environments, dryads and painters like jungle environments and more.
forest
businessman, zoologist and guide
sacred place
Witch doctor and nurse
jungle
Dryad and Painter
desert
Steampunks and Dye Traders
Snow
Electrician Girl, Robot Man and Tax Collector like the snow environment
ocean
Fishermen, pirates and barbers loved the marine environment.
ps: These preferences may affect the behavior and attitude of NPCs. Their transactions in specific environments will lower prices and new goods will appear.