Hard water contains minerals (magnesium and calcium) which in turn causes limescale buildup that can lead to damages. To clean it, the general instructions are to drain the tank and refill it with fresh water, to add a deliming/descaling product, and to then run the machine through a cycle. Your owner’s manual should tell you how many cycles to run for.
You then need to remember to drain and refill the water again. Note that different machines have different instructions for the deliming and that they may recommend a different type of chemical to use in the process.