Taking Mg(OH)2 as an example, Mg(OH)2 is a kind of insoluble electrolyte and will slightly dissociate forming Mg2+ and OH– in water. With addition of HCl, the OH– will react with H+ provided by dissociation of HCl to form H2O. This reaction will force Mg(OH)2 to continually dissociate to provide OH–.