How can avoid double taxation USA and Mexico?

I worked in 2021 to a USA company as a contractor and I lived in Mexico, I paid in Mexico the taxes for almost income got from this company, and I invoiced this money, I got a work visa and I moved in October 2021.

This company hired me as employee in November 2021 in USA, In this year I received the 1099-NEC form and W2.

 

My doubt is if someone can help me how prepare the tax return and avoid a second taxes for the 1099-NEC. that I have paid in Mexico.