The concept of borders is relatively new. Up until a few hundred years ago, countries simply didn't have them. Battles would start simply because "we saw those other guys again! Stop em!"
Control of borders was nowhere near as tight as today, given how underdeveloped technology was compared to today, and in some places (deserts, forests) the border was more of a very wide strip of no-mans land than just a line.
But places like the Roman Empire absolutely had "hard" demarcations in some places, not just standard country borders, but also internal borders.
For example, when Caesar crossed the Rubicon, he legally crossed into Italy by doing so and thus triggered a war. Rome itself had pomerium, a city demarcation whose crossing had legal consequences as well.
If you entered the Roman Empire peacefully, and you had something to tax or apply duties to, you would be confronted with officials in the closest suitable place.