Bible tells that as soon as Jesus was arrested, all His disciples fled and went into hiding. So there was this possibility that whoever known to be close to Jesus would be arrested or tried like Jesus.
Matt. 26:56 But this has happened so that the scriptures of the prophets would be fulfilled.” Then all the disciples left him and fled.
So there could be two possibilities. First: Peter was reluctant to enter inside lest he might be recognised by the people to be disciple of Jesus and land in trouble just like Jesus. Second: Peter was stopped because he was an unknown person trying to enter into a sensitive area.
In case of the “other disciple”: Like the Beloved Disciple, this other disciple is unnamed, closely associated with Peter and characterized as having special knowledge, wanted Peter to come inside to witness the trial of Jesus. Note that John says that this other disciple “knew the high priest and went into the courtyard with Jesus” indicating that in the courtyard this other disciple was not known to be a close disciple of Jesus or else he would have been in the same danger as other disciples.
Gill's commentary says:
If this Apostle is thought to be John, because he frequently speaks of himself in Gospel of John, then he is supposed to be known to the high priest, by carrying fish to his house, and selling it to him; so Nonnus says, he was known from his fishing trade and it is not probable that he was known, or could be known by the high priest, so as to have any intimacy with him; nor is it likely that he, being a Galilaean, would venture in; he was discoverable by his speech, and would have been in equal danger with Peter.
Or possibility is that this desciple was some other disciples of Christ, who had not openly professed him; one of the chief rulers that believed in him, but, for fear of the Pharisees, had not confessed him; or it may be Nicodemus, or Joseph of Arimathea, or the man at whose house Christ had eaten the passover. In the Syriac version he is called one of the other disciples; not of the twelve, but others.
Adam Clarke in his commentary on the bible states that:
For this “another disciple”, there are many conjectures who this disciple was: Jerome, Chrysostom, Theophylact, Nonnus, Lyra, Erasmus, Piscator, and others, say it was John.
Clarke however further says that:
“It is true John frequently mentions himself in the third person; but then he has always, whom Jesus loved, as in Joh 13:23; Joh 19:26; Joh 21:7, Joh 21:20, except in John 19:35, where he has plainly pointed out himself as writer of this Gospel. So in this instance verse, he has mentioned no circumstance by which that disciple may be known to be John.
Conclusion: So Peter was stopped either because he was an unknown person entering the sensitive area or Peter was reluctant to go inside courtyard out of fear that he might be recognised, yet his love for his master brought him till the gate.
Whereas the other disciple, if he is John the apostle, was either not known in the courtyard to be close disciple of Jesus as Gill,s commentary suggest or he was brave enough to face any danger unlike Peter or this other disciple was not from the twelve apostles.