GDP at factor prices

Does anyone know what the logic is to arriving at GDP at factor prices, from market prices? As I understand it, many market prices include some sort of tax (VAT) and/or subsidy, so that ‘actual price’ should equal market price + whatever tax. Anyway, below is the formula from the book. Do you know why you subtract the tax and add the subsidy? Thanks GDP at market prices – indirect taxes + subsidies = GDP at factor prices