Hamas has no marked or listed military structures. They constantly fire weapons and move armaments' throughout a heavily populated city. They scurry in tunnels that pass over hospitals and schools. They have an entire playbook to explain how to take hostages.
Hamas, much like any Islamic group of terrorists, fight with the knowledge that other nations have a set of rules they are suppose to follow when conducting military operations. Civilian targets are suppose to be off-limits, so they will go out of their way to make those locations targets. If a nation doesn't go after the target, then they get to use that spot as a place of rearmament and attack. If the locations are targeted, then it makes the attacker look bad in the international community. And given the fact that Israel has never been given a favorable light throughout most of the international community ever since it was created, its much easier to turn opinion against Israel.
Furthermore, as terrorist groups, they need not fear reprisal from enemy countries. They will launch horrific attacks, hide in another country, in which that country will threaten war, with the fears of starting WWIII, causing most nations to back off and allow the terrorists to continue their operations.
Israel has sent a warning to the entire Gaza area that they needed to leave. But at the same time, Hamas has made the entire Gaza Strip a stronghold where any building could hold threats, and they will make certain that schools, hospitals, and densely packed locations will also have military targets inside or near them. Article 19 of the Geneva Conventions, (which Hamas is not a part of) states that this is a major no-no, and doing these kinda things do make them viable targets. Most countries don't like using Article 19 because of the typical backlash that comes from the international community.
They use these tactics because terrorists will act outside of international law and do whatever they can to cause whatever damage they can. They have their own weapons and connections and don't typically have to worry about an effective reprisal. To them, it 'evens the paying field' when fighting against modern militaries, and allows countries that back them to deny involvement, even as they are funneled weapons and armaments'.