International law limits the manner in which a state can exercise force. The two key legal principles of distinction and proportionality are both designed to protect civilians, while taking into account the military necessities and the constraints of the situation in the field.
While the IDF made extensive efforts to comply with these principles, Hamas totally disregarded them.
Extended Answer