You need a way of comparing different samples of hard water. For most practical purposes calcium and magnesium behave identically, so we need some kind of sum. Sum of masses would be ambiguous, and converting to one compound makes the number much more reliable. As of today it would be much better to express hardness in terms of moles (millimoles) of calcium and magnesium present, but for historical reasons we use the old scale, which predates definitions of moles and equivalents.