What is the logic of including residential house purchases in investment rather than consumption?

When a new house is built, it is intended to last a very long time, and provide a flow of housing services each year to its owner. This is analagous to a firm building a new factory: in both cases resources are used to build something durable that will repeatedly be able to provide a good or service that was previously unavailable.