If a third person comes and joins two who are praying, then the one who is praying behind the imaam should move back, because of the report(required content taken from large hadith) below,
Jaabir(R.A) said: “The Messenger of Allaah (peace and blessings of
Allaah be upon him) stood up to pray, and I came and stood on his
left. He took my hand and turned me around until I was standing on his
right. Then Jabbaar ibn Sakhr came and stood on the left of the
Messenger of Allaah (peace and blessings of Allaah be upon him). He
took both our hands and pushed us back until we were standing behind
-Sahih Muslim Book 042, Hadith Number 7149.
The scholars mentioned that if there is space in front of the imaam and no space behind the two people who are praying behind him, the imaam should move forward, but if there is space behind them and no space in front of the imaam, then they should move back. If there is space both in front of the imaam and behind the two people, the two people should move back and the imaam should not move forward, because he is to be followed and should not move, and because the imaam should pray with a barrier in front of him such as a wall or pillar, etc.