I am not a lawyer, this is not legal advice. If you’d like legal advice consult an acutal lawyer - never accept legal advice from online strangers.
Straight out copying your sorce code to another location without the permission from either you or a license would be considered copyright enfrigement. See https://opensource.guide/legal/ for more information.
So technically you can never prevent this since, well, your code is open source. The only way to prevent it would be to keep it closed source. However, you can - using the correct license - cover this problem up in a “legal” way so you can take action if someone steals your code or tries to impersonate you or your project.