In view of your supplement, extracting ions from the solution is generally to separate these ions from the solution in the form of compound precipitation, that is, adding other reagents to the solution to make calcium and magnesium ions form insoluble and slightly soluble substances such as calcium carbonate and magnesium carbonate, so as to achieve the purpose of separating some ions.
If it is only heated, I think it should be related to the solubility of compounds formed by calcium and magnesium ions. The solubility of some substances increases with the increase of temperature, while others decrease with the decrease of temperature. When boiling, I think these calcium and magnesium compounds will precipitate due to the decrease of solubility, thus achieving the purpose of simply softening hard water.