If they don't have a place to put them, (which they do by the way), then they have no business waging war. That doesn't mean it won't happen of course.
There are open areas in Gaza that could be converted into weapons stockpiles or launchpads, which could be camoflauged and fortified, and perhaps even dressed up to look like a civilian house.
When weapons are placed where civilians actually live, there are a few possible circumstances, and I'll try to hit them all:
1) The civilians are being deliberately used to deter an attack on the area, being used against an enemy with a conscience. The civilians are aware of their role and accept it willingly as part of the war effort. In this case the civilians being killed is not a war crime in any way, the people are equivalent to militants. In this scenario, those who placed the weapons as well as the civilians are to blame for the incident.
2) Same as above but the civilians are unwilling or unaware. In this case their death is still not a war crime (it is akin the babies in Luftwaffe planes as someone mentioned earlier), but it is more unfortunate, more of a tragedy. The responsibility in the case rests solely with those who placed the weapons. In a small way, it is also the civilians' fault for not leaving, if they had known of the threat of course.
3) The militants of country B have no other place to put the weaponry besides the house. Though unlikely this is possible. In my opinion, and this is where it gets shady, it is still country B's fault for arming themselves at all, knowing that it would endanger civilians, but they are less to blame, perhaps a lighter sentencing at The Hague would be in order.
The only time country A would be at fault is if an agreement was within reach or had been reached and they continued the attack, sort of like a battle occurring after the signing of an instrument of surrender, or if country A knew that the weapons were inactive or inaccessible, or if country A knew that the weapons had been moved out. Of course, it is hoped that country A, especially being technologically advanced, will have the discernment to avoid too many deaths over an relatively insignificant few arms, but in the end they cannot be held accountable for these acts.