I accidently contribute to Roth IRA, which should be traditional IRA. How can I fix it ?

Hello tax experts.

I just move to US for about 2 years, and still not clear on tax return.

For the first year, maybe my income is still qualify for Roth IRA, then I contribute to it, with no issue.

So this year, when my fidelity account pop-up and say my Roth IRA is not contribute yet, without a blink of eye I put the money in. And now I am doing a tax return and realize that my income exceed the Roth IRA qualification.

The more issue is, I even put the money in Roth IRA for 2025 !

So I made a withdraw 14k for 2024 and 2025 from Roth IRA, and now I am wonder whether it is the correct move that correct my mistake ?