Testimony from Palestinian witnesses and doctors in Gaza reveal that Hamas and other Palestinian militants regularly abused hospitals and ambulances during fighting with Israel. Specifically by operating inside hospitals and shooting rockets from immediately nearby. Moreover on more than one occasion Hamas attempted to hijack ambulances for there own needs. These tactics endager Palestinian lives and make it difficult for the IDF to distinguish between legitimately military targets and civilians. 

Rockets being near civilian buildings (Oct. 24 2012 Amir Cohen/Reuters)

Firing rockets from populated civilian areas is a common tactic by Hamas and other Palestinian groups. It allows them the protection from retaliation typically afforded only to civilians during war. If Israel does try to retaliate, the likelihood of civilian casualties is much higher which also gives Hamas a huge boost in the PR department against Israel.

This tactic is completely illegal under international law and puts civilians at risk when Israel strikes back at the targets shooting the rockets. This is one of the huge difficulties Israel has to face when trying to minimize civilian deaths while Hamas and other Palestinian groups do all they can to maximize it. This is part of the reason Israel warns nearby residents of impending attacks by dropping leaflets, calling, and texting them. While Israel does to reduce the change of civilians getting killed, Hamas on TV specifically encourages them to avoid these warnings.