Markers, for the most part, serve to identify the border, but in the case of thick forests and vast swathes of barren land, how did people know they were now in foreign territory without any visible demarcations, flags or even natives to ask (still in the said thick forest, for example)? How could I prove I didn't cross into their dominion if someone accosts me?
Generally, they didn't.
We are used to clear lines drawn with modern surveying techniques. While in recent decades satellite technology has made it even easier to draw imaginary lines in the ground, it is since the emergence of the sovereign nation-state that expert surveyors have been employed to map out precise borders.
The modern nation-state also invented border crossings and ports of entry as we understand them. A national road network certainly needs points when it starts and ends, and modern countries like to keep track on who is entering and exiting their borders. But no country in the "medieval period," by any definition, had something resembling a national roadway system. Or even a concept of citizenship as we understand it. Rather, local authorities were typically responsible for maintenance of local roads, as well as the local dispensation of justice and whatever sort of political enfranchisement might have existed.
The medieval period was not only an era before modern nation states, but also an era before mass communication. People's identities, such as they understood them, were typically tied to their local parish, their local market town, or even their neighborhood. Similarly, justice too was local. An aristocrat could cite his privileges and exploit his power in order to extract abusive taxes from his tenants, but tenants might appeal to a higher authority: a court in a nearby town (England had a particularly well-developed system of county courts), the local bishop or abbot (in Italy, Bishops often acted as arbiters of justice), or even a magnate who had authority over the local aristocrat (as might occur in France). Sometimes, guilds, mercantile associations, and professional associations could offer legal support and defend their members. Different parts of Europe developed different customs and approaches to justice.
It goes without saying that a petty aristocrat could easily terrorize innocent strangers passing close to his demesne and extract ransom, or worse. This, in fact, is the original origin of the phrase "Robber Baron." And while a local farmer harassed on his way to a market town might go straight to a local tribunal, someone unfamiliar with local authority figures to whom they could appeal would have very little recourse indeed. This is why mercantile adventures were just as risky as much as they were lucrative, and why they typically required a large and well-developed network of collaborators on whom the merchant could rely on to obtain safe passage for goods.
Predictably, it is in mercantile communities that we see the strongest desire for distinction between nationalities and ethnicities. Seafaring societies with overseas communities might set out to broker a deal with local authorities in order to set up things like a parallel court system in their host country, autonomous taxation systems, and even choose representatives able to intermediate with local authorities in order to guarantee a safe haven and rule of law. Commonly, Mediterranean cities like Venice and Constantinople would have a neighborhood for "guest" communities, and in these communities even less experienced or less well connected travelers could expect to find support among their fellow expat countrymen , ready to help them in their dealings with locals. Sometimes, the representatives of these communities could exert significant political influence, as the Venetian balia did in Constantinople. Other times, these communities were limited to a few streets agglomerating people from a broad region, like Lombard Street in London. Other times still, they could be centered on a single building like the Fondaco dei Tedeschi in Venice. And they could also be sprawling neighborhoods well-integrated into the city's fabric, like the Genoese quarter in Constantinople.
I suppose the crux of what I am trying to say is that borders, and the customs tied to them, are relatively recent inventions. When we envision life in the European middle ages, we must envision a time that is radically different from our own not only in terms of technology, but also in terms of social constructs.