Medieval guilds were town institutions by necessity. A town was where the customers, the raw materials and the fellow craftsmen were concentrated, so that is where a trade had to regulate itself.
Inside those walls a guild controlled who could practise a craft, how long an apprentice had to train, what quality of work could be sold and at what price. It also looked after its members — supporting widows, funding funerals and standing as a body in civic affairs. Being tied to a specific place is precisely what gave a guild the authority to enforce any of it.