Does GDP count both the investment and the house rental? Suppose you bought a new house in the year of 2010. Then the price of the house in counted toward the 2010 GDP. Say then you live in the new house in the following years. So in these years, the GDP includes the housing rental you paid yourself. But then why is it not an overcount? I mean, when we counted the house price into GDP in2010, we have already counted all the utility of the house in one year and there is no need to count the de sequent rental.
You are correct that what you describe would be an overcount, but fortunately, your description of what is counted in GDP is incorrect. When a new home is constructed and sold, the full sales price is not counted in GDP. Instead, only the value of the construction put in place is counted in GDP— when the construction is completed. Then, the value of the stream of housing services (i.e., the imputation for owners' equivalent rent) is counted annually as an output of the asset.

Quoting "How BEA Accounts for Investment in Private Structures":


  In the NIPAs, private investment in new construction
  is measured mainly as the sum of the costs of inputs
  of all construction “put in place,” that is, all
  construction activity completed in a given period. For
  individual projects, BEA’s measure of investment in
  structures includes the following:
  
  
  Cost of materials installed or erected
  Cost of labor and the cost of construction equipment
  rental for the period
  Cost of architectural and engineering work
  Miscellaneous overhead and office costs incurred
  by the project’s owners
  Interest and taxes paid during construction
  Contractors’ profits
  


Houses are therefore counted just as any other capital asset is. Just as a machine that makes bolts first appears in GDP when the machine is constructed then later its output is also counted, a house appears in GDP as output when it is constructed (or renovated) and its output— housing services— is also counted.