If you mistakenly filed a Form 1040 and you need to file 1040-NR or 1040-NR-EZ, or vice versa, you will need to amend your return.
Per the IRS Instructions for Form 1040-X Amended U.S. Individual Income Tax Return, page 5:
Resident and nonresident aliens. Use Form 1040-X to amend Form 1040NR or Form 1040NR-EZ. 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 1040NR-EZ, or vice versa.
To amend Form 1040NR or 1040NR-EZ, or to file the correct return, do the following:
Per IRS Publication 519 U.S. Tax Guide for Aliens, 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 1040-NR-EZ, or vice versa. If you amend Form 1040-NR or Form 1040-NR-EZ or file the correct return, print “Amended” across the top, and attach the corrected return (Form 1040, 1040-SR, Form 1040-NR, or 1040-NR-EZ) to Form 1040-X. Ordinarily, an amended return claiming a refund must be filed within 3 years from the date your return was filed or within 2 years from the time the tax was paid, whichever is later. A return filed before the final due date is considered to have been filed on the due date.