If you build a garage on your neighbor's land, and he doesn't do anything about it, in about 10 years it becomes your land.
False. There’s no such thing as “squatters rights” or anything or a statute of limitations. At any point the neighbor can sue you to protect his land. Further, when either property is sold, a survey will show the discrepency.
In some jurisdictions, you are correct: the state owns all land, and purchase agreements are subject to consent of the state. No bill of sale, no rights. I know that the province of BC in Canada is one such jurisdiction. Irony here being that much of indigenous land in nominal BC is unceded and was stolen without even the pretense of a treaty.
On the other hand, I previously lived in Washington state, US, where one could legally take possession of land after 7 years of use and maintenance (as long as it isn't state or federal land), and as I understand it, a hefty chunk of paperwork.