Because it wasn't Dumbledore's fault, and because he still loved Lily and wanted to do this in her memory.
No one was expecting Pettigrew's betrayal. Remember that it was Lily and James who made Peter the Keeper a few days before the attack. Dumbledore likely didn't know about this, and even if he did, it seemed a reasonable choice at the moment.
As to why he continued to work for Dumbledore, this is the moment when Dumbledore asks Snape to help him protect Harry:
“And what use would that be to anyone?” said Dumbledore
coldly. “If you loved Lily Evans, if you truly loved her, then your
way forward is clear.”
Snape seemed to peer through a haze of pain, and Dumbledore’s
words appeared to take a long time to reach him.
“What — what do you mean?”
“You know how and why she died. Make sure it was not in vain. Help me protect Lily’s son.”
“He does not need protection. The Dark Lord has gone —”
“The Dark Lord will return, and Harry Potter will be in terrible danger when he does.”
There was a long pause, and slowly Snape regained control of himself,
mastered his own breathing. At last he said, “Very well. Very
well. But never — never tell, Dumbledore! This must be between
us! Swear it! I cannot bear . . . especially Potter’s son . . . I want your
word!”
Harry Potter and the Deathly Hallows, chapter 33 "The Prince's Tale"; emphasis mine.
So Dumbledore offered Snape to preserve Lily's legacy, as this is what Snape saw Harry as - Lily's child. Not James', but Lily's; a way to honour her, and a way for him to remember her, by keeping a piece of her nearby. Remember this iconic tearjerker scene:
“But this is touching, Severus,” said Dumbledore seriously. “Have
you grown to care for the boy, after all?”
“For him?” shouted Snape. “Expecto Patronum!”
From the tip of his wand burst the silver doe: She landed on the
office floor, bounded once across the office, and soared out of the
window. Dumbledore watched her fly away, and as her silvery glow
faded he turned back to Snape, and his eyes were full of tears.
“After all this time?”
“Always,” said Snape.
Ibid; emphasis mine.
In the films, Dumbledore additionally says "If you truly loved her..." which seems to swing Snape to his side (starts at 2:43):