This of it this way:
200 years ago, or even 100 years ago, there simply wasn’t the surveying or data storage technology to properly register land. So, you buy a plot, set up stakes and nobody says a word. You build on that land for decades, innocently thinking it’s yours. You build a LIFE on this land.
Then, along comes another party with a claim on the land. Years have passed and now the land can be properly surveyed and, sure enough, you’ve built your life on their property. You never meant to, and you innocently thought you were building on your own property. But, for decades, the rightful owner said nothing. Should you lose that land because of map, surveying or registry mistakes? THAT is what these laws were designed to prevent.
Now, if you KNOWINGLY build or encroach upon someone else’s land, should this law cover you? Definitely not. If the land is properly deeded to another party and both the possession and registry is clear, no third party should have a permanent claim on it. However, most of these laws have not been updated to support those claims.
Even in your example - if it is demonstrable that you were on someone else’s land, even accidentally - and the rightful owner likewise had no way to know for certain - you should have to buy the land you have encroached on (or otherwise make amends/right).
If you knowingly encroach...you're pretty stupid. Is the land yours?? Most towns require a survey to put up a structure...including fences.