Tax is computed after the profit is made. What we're discussing is the question of where the profit was made and which country's tax system it falls under. If any.
(In a corporate structure, which company do you think is legally obligated to maximise profit? The one at the top of the pyramid, or every individual registered company?)