Many filters use the principle of adsorption to remove contaminants from water. Activated charcoal particles in the filter have a slight electrical charge, and when contaminants in suspension pass through the filter, this charge draws them away from the water molecules and traps them in the filter.
Molecules can have electrical charges if they have more or fewer electrons than they should. Water molecules are polar, which means they have a strong negative charge on one end and a strong positive charge on the other. This is what allows substances to dissolve so easily in water, as the molecules of the contaminant bond with either end of the water molecule. Charged particles in the filter break this bond, purifying the water.