Thank you to everyone who submitted solutions to this problem.
Julian, from the British School, Manila, in the Philippines, produced some diagrams to show how to connect the houses and utilities when there were two utilities. His method shows that you can connect as many houses as you want to the two utilities:
He was also able to use the same method to connect the three utilities to two houses:
Rhiannon explained why it is impossible to connect all three utilities to all three houses:
Arrange the houses and the utilities in a hexagon, with the utilities and the houses alternating, as in the diagram. Adjacent houses and utilities are connected together.
Each utility must then be connected to the house that is opposite it as well. One utility can have this done inside the hexagon, say the gas. Another can have it outside the hexagon, say the electricity.
Then the loop marked in green has the water on the inside and the house on the outside, so there is no way to connect them.
If instead the electricity had been connected on the other side of the loop, the water would be outside and the house opposite would be inside, and they still couldn't be connected.
Srija was able to show that it can be done on the surface of a doughnut, because you can make use of the hole! Here is the method she used:
Notice that the yellow electric connection goes behind the doughnut, whilst the red gas connection goes all the way round.