I lived off sales of stocks last year due to unemployment. I paid 15% for each stock sale for federal taxes. Why isn't that amount being deducted in the tax owed?

I sold about $300,000 of stocks to pay for the restoration of a cottage on my property but had no earned income. Those stocks had a 15% tax associated with each sale. Why isn't it applied to my federal tax owed?