This remark from Macduff, in the context should be taken to mean, "Why did I have to be away from home when this happened?" He is angry with himself for not having been at home to protect his family.
This anger was shared by his wife, who blamed him for leaving Scotland and even told their son "Your father's dead" and called him a traitor. The problem here is that Macduff only left his family behind in order to go to England and persuade Malcom, the true heir to the throne, to come back to Scotland and overthrow Macbeth.
Macduff's actions may have saved many more families from a regime where "Each new morn/New widows howl, new orphans cry." He felt it was right to put country before family, but when he hears the news of his family's death he feels it was wrong to leave them ("Sinful Macduff, they were all struck for thee.")
The play doesn't really show him as either right or wrong: it just shows us that Macbeth's regime forces people to make very hard choices.
Macduff's priorities seem to be first with country, then with family. There are several examples to support this claim -- he left his family to find Malcolm without explaining his absence to them, he mourns for his country after Malcolm recounts all his vices, he uses the deaths of his family to spur his eagerness in battle.
Before judging Macduff too harshly, though, we must remember his response to his family's murder. He seems to be in shock, repeatedly asking if they are all killed. We must remember as well that Macduff is a foil to Macbeth -- his loyalty to country above family is contrasted with Macbeth's disloyalty to country for the sake of position.
We must remember as well that in the Elizabethan culture, the king was seen as having God's authority. Macduff's eagerness to restore the right king to the throne could be seen as both a patriotic and religious mission. Finally, we learn that Macbeth has become a tyrant in his reign. Macduff's determination to bring Malcolm back is for the greater good of all, including his own family.
Therefore, while on the surface Macduff appears to put country before family, we can see the bigger motivation behind his actions and conclude that his family holds a place of high importance in his life and actions as well.
Macduff certainly did not expect Macbeth to have his family massacred. Otherwise he would not have left them. What Macbeth has done is probably unprecedented. It is ignoble to murder women and children. Macbeth is acting like a madman. At the end of Act 4, Scene 1, when he is told that Macduff has fled to England, he says in an aside:
Time, thou anticipat'st my dread exploits.
The flighty purpose never is o'ertook
Unless the deed go with it.
Evidently he was planning to have Macduff himself assassinated, in which case he might not have injured his wife and children. He decides on the spur of the moment to take revents on Macduff's family. No doubt Macduff thought they were safe in a castle fully guarded, but Macbeth says to himself:
The castle of Macduff I will surprise,
Seize upon Fife, give to th' edge o' th' sword
His wife, his babes, and all unfortunate souls
That trace him in his line.
Macduff thought his family was safe, but his castle is taken by surprise. Macbeth wants to set an example so that any other thanes who might have been thinking of defecting will be forced to remain in Scotland and at least pretend to be loyal. Many turn against him when Malcolm and Macduff return with the English army.
Macduff should not be accused of deserting his family and leaving them defenseless. He could not have anticipated Macbeth's tyrannical savagery.