If you mistakenly filed a Form 1040 U.S. Individual Income Tax Return and you need to file Form 1040-NR U.S. Nonresident Alien Income Tax Return, or vice versa, you will need to amend your return.
Per IRS Instructions for Form 1040-X Amended U.S. Individual Income Tax Return, on page 8:
Resident and nonresident aliens. Use Form 1040-X to amend Form 1040NR. Also, use Form 1040-X if you should have filed Form 1040 (or, for years before 2018, Form 1040, 1040A, or 1040EZ) instead of Form 1040NR, or vice versa.
To amend Form 1040NR, or to file the correct return, do the following:
For more information, see Pub. 519, U.S. Tax Guide for Aliens.
Per IRS Publication 519 U.S. Tax Guide for Aliens, on page 35:
Amended Returns and Claims for Refund
If you find changes in your income, deductions, or credits after you mail your return, file Form 1040-X, Amended U.S. Individual Income Tax Return. Also use Form 1040-X if you should have filed Form 1040 or 1040-SR instead of Form 1040-NR, or vice versa.
Note that any link in the information above is updated each year automatically and will take you to the most recent version of the document at the time it is accessed.