I received a 1099-R with code P for the excess deferral contribution I made in 2017 which was reported in March 2018 but the check was not issued until April 20, 2018. I also received a second 1099-R for this same excess deferral PLUS the earnings and it shows code 8. I put my return on extension so technically I received the return of the contribution before the due date of the return. How do I report this on my 2018 return so I am not being taxed on this money twice??
Because the distribution was made after April 15, 2018, the excess deferral is taxable in both the year of the excess deferral and the year of its distribution. The code P Form 1099-R shows that it is taxable on your 2017 tax return (the year of the excess deferral) and the code 8 Form 1099-R with the entire excess and earnings shown as taxable is taxable on your 2018 tax return. Because the corrective distribution was not made by the deadline, it's indeed subject to double taxation, unfortunately.
If your filed 2017 tax return did not already include the amount of excess deferrals in income, you must amend your 2017 to add this income. You can do this by entering the code P 2018 Form 1099-R into 2017 TurboTax if the form shows the gross amount as taxable.