Gallstone formation has to do with the relative concentrations of each ingredient in bile. Bile acid binding resins waste bile acids, leading to an increased concentration of cholesterol in bile relative to the other components == promotes gallstone formation.
The reason they lower cholesterol is because they promote the liver taking up cholesterol to produce more bile acids.
Cholesterol blockers simply decrease intestinal absorption of cholesterol, which decreases blood cholesterol levels.