The amount that you just received via direct deposit could be one of two things:
First, it could be your actual tax refund. You would know if it is this because the amount you received should be the amount that was on the bottom of your Form 1040 (Line 35a). Yes, if you filed Form 1040 when you should have filed Form 1040-NR, you may have calculated too large of a tax refund, because non-residents are not eligible for some of the tax credits, especially the stimulus Recovery Rebate Credit. You will certainly need to correct this. To do so, you file an amended return on Form 1040-X. As was noted in the comments, you can do this even if "2020" isn't listed as an option at the top by writing in "2020" in the space provided. If you find the right tax software, it should be able to help you out with that process, and you'll need to send in whatever the difference between the refund you got and the refund you were supposed to get.
Instead of your tax refund, it could be the third round of stimulus, which started appearing in bank accounts via direct deposit this past week. The amount of this is $1400 per person in your household (or more or less depending on certain things). If the amount you received does not match what you had on your tax return, it was probably this. If so, I can't answer whether or not you will get in trouble if you keep it, or whether or not they will ever come asking for it back. But the IRS does have an answer to the question on how to return it:
Q I1. What should I do to return an Economic Impact Payment (EIP) that was received as a direct deposit or a paper check? (updated June 9, 2020)
A1. You should return the payment as described below....
If the payment was a paper check and you have cashed it, or if the payment was a direct deposit:
- Submit a personal check, money order, etc., immediately to the appropriate IRS location listed below.
- Write on the check/money order made payable to “U.S. Treasury” and write 2020EIP, and the taxpayer identification number (social security number, or individual taxpayer identification number) of the recipient of the check.
- Include a brief explanation of the reason for returning the EIP.
The page then includes a list of different mailing addresses to send the returned payment, based on your location. It looks like if you live in a foreign country, you send your payment to the Austin, Texas location.
A note at the top of the page says that the information is for the first stimulus payment, but I would guess that the procedure would be the same for the second and third stimulus payments. Instead of writing "2020EIP" on the payment, you should probably write "2021EIP" on it.