Shaikh al-Albani rahimahullah said:

“That which I want to say is that one person prays to the right of the Imam and as well he places his shoes to the right. If another comes and he does not know the nature of the ruling so he stands on the left of the Imam, then the Imam here follows the Prophet sallahu alahyhi wa salam and puts them both behind him. As for if the second has understanding that the two stand behind the Imam, then he stands behind the Imam and pull the one on the right. As for the Imam, then he remains in his place and he is not ordered to move forward. Yes”

[Silsilatul Huda wan-Nur no. 812 Side A]

Shaikh Bin Baz rahimahullah said

Question:

There are two people praying asr in congregation and a third comes after both have entered prayer. So the Imam precedes because there is no place behind for the congregants to return to. So is it allowed for the Imam to come forward, specifically since we know the Hadith that the Messenger of Allah sallahu alayhi wa salam moved two people back and the Imam did not move forward?

Answer:

If the Imam is in a place where it is possible for him to move them both back, then he moves them back. If the Imam is in a place where it is not possible for them to move back, he moves forward and there is no blame nor harm. What is important is if there is space in the place. If the space is behind, then he moves the one with him behind along with the other and they both pray behind him similar to what the Prophet sallahu alayhi wa salam did when Jabir (may Allah be pleased with him) and Jabbar came and stood on his right and left. So he put both of them behind him. Likewise, the story of Anas and the orphan. He placed both of them behind. As for if they make a row against a wall and all of those behind him are against a wall. Then the Imam moves up and leads them and this is legislated. May Allah bless you and reward you with good.

[Reference]

Tranlsated by

Faisal Ibn Abdul Qaadir Ibn Hassan
Abu Sulaymaan