This is often misunderstood and varies by jurisdiction. Often called "squatter's rights", it is often thought to mean "if I use this land for a long time without anybody noticing it becomes mine", but e.g. in my jurisdiction, you also have to have prove that you didn't know it wasn't yours. For example, if your backyard fence has been 5 feet over the property line for 10 years and nobody noticed, but then suddenly your next door neighbor has the property surveyed and tells you to move your back fence, you can take them to court and potentially claim that extra 5 feet as your own. But you can't just scoot your back fence over a couple inches every year and then eventually lay claim to your neighbor's backyard because they didn't notice it was shrinking, nor can you "find" "abandoned" land, build a house on it, and then claim it as your own. I believe there are a few jurisdictions where this actually is the case, but it's fewer than many people believe. And then of course you have the reality of squatters invading people's homes while they are on vacation for a week and the police being completely unwilling to get involved, which I understand was a big problem in France for a while.
IANAL