During Jesus's time, King Herod had sent his soldiers to kill the people of the church. In the chaos James the brother of John was killed.
The king then had Peter captured and arrested.
Peter was then thrown in a prison cell where guards watched over him until it was time for him to be handed over to his people. On the last day of his stay, the church had made a prayer for him.
Because the church had made a prayer for peter's safety God had sent an angel to help Peter escape from King Herod. Originally Peter did not believe that he was seeing an actual angel, he thought he was seeing a vision.
The angel guided Peter to the gates of the castle who still thought that everything was a vision. once they found the iron gates the angel made them open by themselves which finally convinced Peter that the angel was real
Once the two walked out the gates the angel had left Peter which made Peter realised that god wanted him free.