yep, ever heard of tax credits, refunds, rebates and creditable deductions?
if you remit or pay taxes on your quarterly returns or on your withholding taxes but it turns out you suffered losses in total or that the amount due on taxes are less (as stock prices do rise and fall on a regular basis), you can claim a refund on the excess on what should have been lawfully due and properly paid. the government sends you a check or a certificate which you can use like real money (because it is real money anyway).
there's just no accurate way to determine the tax basis of the rise and fall of stock prices in the market. so if you treat appreciation of assets as earned income, you got a situation where you make the government pay back people for taxes that should not have been paid for the year.
this system would have been probably disastrous around 2007-2008 when the stock markets collapsed.