Closing stock is not just opening stock+purchases-sales.
This formula will completely ignore the value addition taking place in the business. (and obviously the profit margin)
It is not possible to allocate the value addition in the form of overheads with the formula.
Hence we take the closing stock physically, identify normal and abnormal losses, allocate overheads and related expenses and arrive at cost of the stock.
Then we compare with the net realiseable value, and take the lower value of cost or NRV, because closing stock value represents resource controlled by the enterprise from which economic benefits can be expected to flow o the enterprise, i.e., closing stock represents an asset.
This closing stock is shown in the trading account as an income. Why? Matching concept of accounting. The purchases and overheads incurred by you - their benefit will be obtained only in a future period. Thus it results in matching the expense incurred with the benefit to be derived in the accounting period.
Also , when u take the NRV of the stock, you are writing off a loss (diff between cost and NRV), thus recognising the correct profit or loss for the period.