This was unsatisfactory to Matthew and Luke, who both omitted the reference to "twice." That left Jesus predicting that Peter would betray him three times before the rooster crowed. Peter did so and then the rooster crowed. This is a tidy story.
Some of the scribes who copied Mark also found Mark's story to be messy. They tidied it up either by omitting any mention of a second crowing (Matthew's and Luke's solution) or else by expanding with a reference to a first and second crowing in the event. The latter solution is implausible, because we are supposed to believe that the rooster crowed just after Peter denied Jesus the first time, Peter didn't notice and he went on to deny Jesus twice more, then the rooster crowed a second time. Only then did Peter remember Jesus' prediction. This is psychologically unlikely. But it at least removes the original loose end of "twice" in Jesus' prediction.
As the text of Mark continued to be copied, other scribes corrected it back and fourth, making the manuscript tradition a bit messy again.
I don't know if my reconstruction is correct. But it is tidy.
Visit PaleoJudaica daily for the latest news on ancient Judaism and the biblical world.