Schools, hospitals, places of worship and other such have a protected status. If used by an armed force in a way which abuses this status, the other side may attack them despite the protected status. It's been referenced multiple times by now on relevant topics (and obviously, on past ones).
Hamas leadership is on record saying that the civilian casualties are necessary sacrifices for 'the cause'. Other vile comments about blood of children etc. These were mostly made by leadership figures well away from the fighting, in the safety of Qatar and elsewhere.
For Hamas, civilian casualties represent PR points, a recruitment opportunity, and a monetary value.