Israel says both raids were aimed at stopping militants from firing rockets and mortar shells at Israeli settlements and towns .