Guild
A guild is an association of people, who come together for a number of reasons. The reason for this can be anything, from creating a merchant's guild to centralize trading, an adventurer's guild to gather like-minded individuals to quest together, to a craftman's guild to hone their craft better by gathering everyone to share their methods and such, and many more. A guild can also be a secret cabal of people working together in the shadows to achieve some greater goal.
When a guild is officially recognized by the state they're in, a guild is capable of being a self-governed body who can enforce certain rules pertaining to their focus and be granted special rights, which can either be good or bad, depending on the setting. Those versed in the ways of /v/ might recognize the term used to designate groups of players working towards a common goal, but most of the time this ends up being "raiding" and "kill big stuff", meaning there's little difference in between them aside from overall skill level.
Guilds in Fantasy
As mentioned above, guilds in fantasy typically refer to the player-created ones where like-minded players come together and pool their resources and assistance for the benefit of everyone, although this is not the only way guilds make their way into settings.
Being a collection of professionals versed in their craft, guilds typically act as a hub for players to get better access to stuff. Blacksmith guilds only recruit skilled smiths, so players could have the smith there craft them a high-level piece of equipment, or a warrior's guild is comprised of hardened veterans, so players could find experienced warriors there to teach them new skills, and so on and so forth.
Guilds can also be a source for setting backgrounds, given that they could, in theory, do fuck all and monopolize their services as they see fit. For example: a merchant's guild has the right to control the trade of all goods in their territory. In order to make sure they're top dog; they make sure that every trader who wants to sell stuff has to be a member of their guild (where you would have to regularly hand them a cut of your profits), otherwise, they can legally have that trader arrested. However, the guild is run by money-grubbing assclowns who know they're the only source of vital trade in the land, so they jack up the prices of their goods and demand unreasonable shares from their merchants, overall making everyone poor and unhappy. Tired of this, people then request your aid in bringing them down.