The quick answer to your broader question is that there are multiple ways of slicing how GDP is computed, and yes, economists are aware of them and have thought through the edge-cases as well as being aware of where the measures fall short.
E.g. in your example, see the Value-added approach: https://quickonomics.com/gross-domestic-product-gdp/