Why are there so many townhouses being built rather than single homes?

Especially in one of the cities that’s just booming. Is it just because of cheaper costs and that you can densely pack a group of homes? Or is it easier to build?