Yea, even townhouses are going to be better on average than single family houses.
Shared walls are, of course, like perfect insulation.
They are also generally smaller, so you are just heating less volume.
And they are generally putting more people on the same sized lot, which means a lot less landscaping water.
Further they are generally closer to work and amenities, so you drive less.
Sure an old multifamily building will be less efficient, but so are many old single family houses.
And there are lots of minimally maintained single family houses around. I once rented part of one which had single pane plastic windows which were popping out of their frames leaving gaps even when closed. Hideously inefficent place. Though with 6 people in it, still a quite efficient lifestyle.