Before you keep reading, keep in mind I’m not a lawyer.
As far as I’m aware, in a lot of countries, when you publish a project, you are automatically the owner of it (and own all rights to it). Would be best to check how it works in your country.
What you are referring to, is called piracy. It’s when people share your project with others that haven’t bought it. This has been a problem for a very long time. So far, even today, companies with millions of budget haven’t found a way to solve this without making it too cumbersome for regular users.
Some companies have managed to get around that by putting subscription on games, or making them online only, but it’s not eliminating the issue, just reducing it.
If this is your very first game, I would suggest you don’t pay much attention to piracy. At this level, your time is best spend training your skills, and making even better games. Just make sure your name (or nickname / company name) is visible somewhere in your game, preferably in a place that is very difficult to remove by a third party. That way, even if your game is stolen, and posted to other places without your consent, people playing the game can still know it’s made by you, and potentially search your name online to find more of your work.
You can always register the name of your game to prevent others from using it, but most indies don’t do that, at least not until they’ve managed to generate some revenue.