Should have been titled "... in the USA" as tax rules are very different in other countries. For instance, in France, you only owe money to the taxperson when you sell your shares, for a profit. If you sell for a loss, this is tax-deducible.
The US really does have a lot of problems with their tax system to be honest. For a country whose citizens outwardly hate tax, you'd think they would have one of the best, most straightforward, and fair tax systems in the world. But instead you have one of the most convoluted, loopholey, broken systems in the world. Whereas in countries where taxes aren't as "hated" (Europe, Canada, etc) they don't pay a cent to file…
It doesn't, but because of the complexity of the tax system most people either use a tool like TurboTax or an accountant, to file for them; that costs money.
And the reason it exists, the lobbying of special interest groups for exceptions to taxes. If you can convince people in government that you deserve a break b/c what you're doing benefits society somehow, there's a tax loophole waiting for you too!
And now, there is the multi billion dollar industry that depends on this complexity and doesn't want it simplified. This is a huge waste, we waste money individually that could be spent on actual goods, and the IRS/government waste money needing to audit all the people who decided that maybe they did deserve a tax credit that perhaps they did not.