Medea would have done anything to be with Jason. These aren't just words; she backed up her passionate love for Jason with action——namely killing her own brother Absyrtus before she fled Colchis with her beloved. But now that he's betrayed her, gone off to marry Glauce, she will do anything for revenge, even if it involves killing her own children. The intensity of Medea's love is matched only by her hatred towards the man she once adored.
Medea's actions could plausibly be justified on the grounds that she's an instrument of divine will. Her falling in love with Jason was the work of Aphrodite or Eros, so Medea, as with so many mortals in ancient Greek myth, is a pawn in a much bigger game being played by the gods. Medea's killing of her children, though utterly reprehensible from the standpoint of human morality, does appear to be sanctioned by the immortals, and Medea knows all too well what happens to those proud or foolish enough to defy the gods. Indeed, one could argue that it is Jason who has offended the gods by dumping Medea and entering into an unfaithful relationship for purely political advantage.
This impression is confirmed by the deus ex machina that helps Medea to evade justice at the end. The chariot of the sun-god Helios swoops down, whisking Medea away along with her children's dead bodies. We may look askance at Medea's despicable acts, and not just in relation to her children, but the gods clearly smile upon her. And ultimately, for the ancient Greeks, that's what really matters.