Tankless water heaters are pretty efficient, but when you need hot water, you briefly use huge amounts of energy. It's for this reason that they almost always use natural gas. Electric tankless heaters are a great way to cause brownouts. They're roughly the size of a microwave oven, so they can fit in pretty much any kind of dwelling.
Water heaters with tanks, on the other hand, take up huge amounts of space and require frequent (but lower) energy input. This can use heat from a variety of sources, including low quality/unrealiable heat sources like solar heat pipes.
Then there's space heating. Unless you live in a Passivhaus, keeping a comfortable indoor temperature is challenging. Central heating using hot water and radiators is the most common approach where I live. But this again relies on burning hydrocarbons. Or, increasingly, on heat pumps, which require a lot of space, are noisy, and drop in efficiency as the temperature drops.
As far as I can tell, there are no silver bullets in either space heating or water heating. If you have a really big house, a big tank is probably a good solution for hot water. But living in a really big house is horribly inefficient in its own way. So I'm guessing that's not the greener approach. Living in a smaller dwelling is more efficient. But it seems there are basically zero good ways to heat small living spaces and hot water for a family of 1-2 living in small houses.