It's possible that Peter didn't die because he still had more work to do. He had epistles to write. Besides, you can't say that he lived simply because the church prayed for him.
from https://enduringword.com/bible-commentary/acts-12/
e. And has delivered me from the hand of Herod: James was martyred (Acts 12:1-2) and Peter was rescued. The reasons God does such things, or does not do them, are often known only to Him. We do know that James, having graduated to glory, did not consider himself a loser in any way.
i. Simply, it wasn’t time for Peter to go to his heavenly home yet. Until it was time, he was invulnerable. He couldn’t be harmed. It was time for James; it was not time for Peter.