In this moment of history, geographic state borders are defined in official treaties between countries. These treaties determine where the territory of certain state ends and where the territory of the other one starts, by using e.g. certain latitude or following the course of a river. I suppose this type of official attestation was developed around the 18th or 19th centuries.
I want to know how did the border came to be, specifically in Europe, and I'm particularly interested in knowing how (if at all) was the concept of the border treated during the Middle Ages.
EDIT: Changed the question to be specifically about borders (as that was what I originally wanted to know).