It is largely Jihadi Salafi groups firing the rockets, groups that are actually opposed to Hamas, which is why it is easier to recognize the overzealous targeting of Hamas in the campaign. the same was true of their search for and accusations surrounding the missing students which third party groups claimed responsibility for, but which Netanyahu took the opportunity to blame on Hamas instead and used it as a justification to illegally harass and target Hamas affiliates.
Easy. Because these Salafist groups are operating because of either the incompetence of Hamas, or their weakness, and because of the acquiescence or support of the civilian population.
Collective responsibility merits collective punishment. Gaza's population supported Hamas, and acquiesces to, if not outright supports the Salafists. It makes absolute sense to hold them collectively responsible for allowing terrorists to operate amongst them.
There's never been a good example of an occupying force succeeding with a population-centric counter insurgency strategy. The most successful examples of crushing insurgencies, like Sri Lanka, involved a willingness to use violence and force to achieve victory.