From Wikipedia, investment in macroeconomics is the purchase of goods that are not consumed within a short amount of time (say 3 years). In this sense, home purchase seems to be a form of investment. However, as per my understanding, investment should also involve purchasing new capital goods, which seems to me that primary residence does not qualify. I'm quite confused here: do we consider homes which are only used by their owners as investment, even if these homes are newly built?
Home construction is a form of investment, home purchase is not. There's an important macro difference between creating the capital asset (construction) and transferring it (purchase).
Regarding whether a newly built home occupied by its owner counts as investment— yes, because it is a capital asset that produces a stream of housing services. There's more detail on how this fits into GDP in this answer.