Both in Economics and in Accounting, there is the following fundamental principal: we have to subtract revenues generated in a given time period from costs incurred in the same time period (because this is what makes basic sense).
Now, "cost" is the value of productive resources absorbed into production, in the given time period. The total value of an "Investment" is not absorbed in the usual time period where firms record their profits (month, quarter, year).
When we buy a machine, we use it for many years.
So only a part of "Investment" is absorbed in a period (essentially what constitutes an "investment" and what an "(operating) expense" is based on this criterion exactly -whether it is fully absorbed in production in one time period or not). The total value of Investment done in say one year is an outflow in the Cash-Flow statement, but it is not a Cost in the Profit and Loss statement.
And, as you mentioned, that part of the Investment that was absorbed in production during the period, is reflected in the calculated Depreciation, which is chraged as a cost to the Profit and Loss statement.