The Israeli military said it targeted the men because they had plotted an attack in Israel that took place in August and were planning another attack. The first claim can't be true, casting doubt on the credibility of the second.
One cannot properly judge these recurring incidents without keeping in mind the full context. The Gaza Strip, which Israel has controlled since 1967, has been blockaded by the Jewish state since 2007, after Hamas won elections there. The Israeli government restricts the flow of goods into Gaza, and one Israeli official has joked about putting the people there on “a diet.” Efforts to break the embargo by human rights activists have been met by force, most egregiously in the 2010 Mavi Mamara incident in which Israeli commandos boarded the ship and killed nine activists, including a young American citizen, Furkan Dogan. Smuggling of goods through tunnels across the Egyptian border has mitigated some of the hardship from the embargo.
In 2008-2009 the IDF killed more than 1,200 Palestinians in Gaza during a three-week air and ground assault known as Operation Cast Lead.
As for the larger context, many residents of Gaza are refugees or children of refugees driven out of their ancestral villages by Zionist paramilitary forces in 1948 in an effort to establish the Jewish state with as few Arab residents as possible. See my previous post “Gaza, Sderot, and Najd.”
In other words, the context is one in which the Israeli government is the oppressor and the Palestinians in Gaza, which amounts to a large concentration camp, are the oppressed. Israel could bring an end to the rockets on civilian neighborhoods by ceasing its unjust treatment of the Palestinians in Gaza, as well as in the West Bank and Israel.
For more, read Gideon Levy's Haaretz analysis, "Way to Go, IDF!," Ali Abunimah's "'Mowing the lawn': On Israel’s latest massacre in Gaza and the lies behind it," and Max Blumenthal's "Israel's bogus case for bombing Gaza obscures political motives."