What I was taught years ago was that the stones formed around a piece of debries - bacteria, dead parasites, bits of food. Stones can form in the bile ducts in the liver and in the gallbladder (not to mention in the pancreas and kidneys). There are cholesterol stones, stones that have calcium and are hard and stones that are soft, not to mention sludge that can clog up the bile system. One stone I passed had a piece of an old metal filling embedded it it. For a good overview search for 'why do galstones form'.