Although there are differing schools of thought, the most prevalent seems to explain that, as you surmise, the original craftsmen in stone; i.e., masons were required to be members of a guild (as were other craftsmen, such as carpenters) to preserve the "secrets" of stone working and fitting, especially during the period of building the huge stone churchs and official buildings. The original masons were, by statute (on the Continent, especially France) limited in what they could charge or earn per diem. The wording of the statute (about 1350 AD) included the term free stone masons of different ranks. It's thought this was the genesis of the term "freemason".
It's also thought the guilds previously mentioned, gave the stone masons freedom to travel from job to job and be quaranteed a wage as opposed to other masons that stayed near their home area, primarily within the feudal system of the middle ages. This "freedom" of movement also lent itself to the term "freemason"...