You can go to your nearest military post and ask the finance office for a copy of your W-2 for those years.
If you were in the reserve, you can obtain past year W-2 by using the services at:
If your nearest military finance office is not able to help you, the only way you can get a copy of your W-2, is from the Social Security Administration office. While the IRS may keep a data tape, it does not keep copies of the W-2, except for as part of an already filed return.
The IRS will send you to the Social Security Administration to obtain a copy. I always have somewhat better luck contacting the SSA than the IRS.
Please try these directions taken from the IRS web site:
Topic 159 - Prior Year(s) Form W-2 (How to Get a Copy of)
The IRS does not retain actual copies of Form W-2 (PDF) except as an attachment to your tax return, for prior years. However, the IRS maintains (and will provide free of charge) Form W-2 information for any purpose for the past ten processing years. The only way to get a copy of your Form W-2 from IRS is to order a copy of the entire return on Form 4506 (PDF), Request for Copy of Tax Return, and pay a fee of $39.00 per tax year.
The Social Security Administration will provide copies of Forms W-2 for retirement purposes at no charge and for other than retirement purposes for a fee.
Call 1-800-829-3676, or visit the IRS web site at www.irs.gov to obtain Form 4506, Request for Copy of Tax Return, or Form 4506-T (PDF), Request for Transcript of Tax Return, to order the information from the IRS.
Call 1-800-772-1213, or visit the SSA web site at http://www.irs.gov/app/scripts/exit.jsp?dest=http%3A%2F%2Fwww.ssa.gov for instructions on how to obtain wage information from the SSA.