First thing: A common theme in the Fate franchise is "Rules? Screw your rules. I'm a mage/servant/noble phantasm/whatever." The true competition is not in competing in accordance with the rules (no matter how much Ruler tries to say otherwise), but in breaking the rules better than the others. In this vein, Shirou forcibly activates the greater grail. It is a system that was designed to be interacted with by outside forces, and he uses that to his advantage.
Second thing: The condition to granting a wish is not "only one servant remains," but rather "sufficient energy has been collected through the expiration of servants, and other servants are not currently getting in your way to stop you from activating the grail". The (greater) grail basically works as follows:
- Draw magical energy from a ley line.
- Use that energy and the promise of a wish to cause Servants to coalesce.
- The servants have their own magical energy which is (much) greater than what you used to bring them there.
- When a servant dies, they are "filtered" through the greater grail system. The grail claims their magical energy for itself.
- Grail now has way more magical energy.
In the first war they only summoned three servants, one for each of the families involved in its construction, but they couldn't achieve much with only that much power; especially not their goal of reaching the root. So they decided that to ensure that the Grail got a large enough supply they would need around 6 "average" servants to expire, so they adjusted it to summon a total of 7.
In the Apocrypha grail war, the Clock Tower is able to activate a safety routine that causes a double-scale war to be initiated. It was designed to only need to summon 7 average servants, but now there are 14. This then triggers another safety routine, which summons Ruler. So in fact only 6 servants of average strength needed to be eliminated for the Greater Grail to have enough power to grant a wish, up to 14 are available (counting Ruler), and fewer will suffice if there are exceptionally powerful servants (Black Assassin would be below average, but Red Rider is well above average, etc.). Combined with a forced activation you don't need to kill everyone, especially in a double-size war. You just need to have enough control of the situation to not have your wish-making interfered with.