The laws are reasonable - they allow costs to be offset when calculating profits.
The problem occurs because
A can sell to B at cost who can sell to C at the price that C finally sells for and the only person making any profit is B.
Perhaps the market is very competitive, A cannot sell above cost. C cannot buy at below the price B will sell at. (obviously in the real world A and C would need to make some profit but it's not inconceivable that A and C are working with margins of less that 5% while B is working with a 40% margin.)
Or perhaps A, B and C are all subsidiary companies of the same parent. It's still possible that A and C are in a very competitive market, or it's possible that the company is artificially moving profits to where they would prefer them to be.