Basically, ma'aser is given on net income rather than gross income. My Rav has said that the basic concept is that one treats 'income' as the net after expenses. Taxes are considered as expenses in this view. As a result, when calculating ma'aser, taxes withheld are treated as expenses and tax refunds are treated as income.
The comment above by @bondonk mentioning the Igrot Moshe that tax money is 'never earned', would fit with this explanation. It is subtracted from the total amount used to calculate ma'aser (as an expense), not treated as a ma'aser payment.
Many people use the net pay after withholding for the calculation. The 401K is also not treated as income since it will be treated as income after retirement when the money is withdrawn from the account.
Maaser Kesafim and the Development of Tax Law
This article explores the development of the rules of Maaser Kesafim, the Jewish practice of non-agricultural tithing, and compares the income definition rules found in the halacha to those found in the Internal Revenue Code. The ancient rabbis and those who crafted the Federal tax rules stuggled with similar issues in deciding what should be included in income and what deductions should be allowed. Comparing the two regimes and how they address those issues reveals the extent to which culture and different enforcement mechanisms affect the development of the law.
Text on this
Maaser Kesafim: Giving a Tenth to Charity Domb, Cyril (editor) Halacha Feldheim 1999
From times of old it has been an honored Jewish practice to give maaser, a tenth of our earnings to tzedaka, charity. Yet a great many questions arise when we proceed to fulfill the mitzva. For example: how is income defined? Are capital receipts subject to the obligation of maaser? If they are, how should indivisible assets be dealt with? Is there a specific "tax year"? What expenses are allowed? How is capital investment to be dealt with? How are charities defined, and is there an order of priorities in the matter? To find answers, a research team of the British Association of Orthodox Jewish Scientists made a careful study of the Shulchan Aruch and the responsa literature. Where no clear-cut answers could be found, the next step was to turn to the great Torah authorities of our day. This book is a record of the results of their investigations.