Shelter is an expense. Like many things, you can own it or you can rent it. Owning it means you're holding an asset that (hopefully) won't depreciate but it is also unlikely to meaningfully appreciate (outside of certain local market conditions that are the exception rather than the rule).
Back to the original point: in order for an education to be an investment, the degree - the asset - must have a reasonable expectation of going up in value over time. The value of your degree goes down over time as you gain work experience; its peak value is right after you graduate. An argument could be made that the return on investment is a rise in earning potential but that too is a one time boost. A degree also shares all the bad qualities of housing as an investment: high leverage, even worse - zero! - liquidity, and low diversification.
It might make financial sense to borrow money in order to fund a degree, but that by no means makes education an investment.