Praise be to Allah
This matter is broad in scope, in sha Allah. He may pull him back whilst he is bowing, or he may stand with him, then when they rise from bowing they may both move back.
It says in al-Minhaaj: The male should stand on his (the imam’s) right, then if another man comes he should say the takbeer of ihram (to enter the prayer) standing on the imam’s left, then the imam should step forward or they should step backwards, which is preferable. End quote.
Al-Khateeb ash-Sharbeeni (may Allah have mercy on him) said:
If another male comes, he should say the takbeer of ihram (to enter the prayer) preferably standing on the imam’s left. Then after entering the prayer, if it is possible either to step forward or step backwards, the imam should step forward or they should step backwards, whether they are standing or bowing, as our Shaykh said.
End quote from Mughni al-Muhtaaj (1/491)
al-Bujayrimi (may Allah have mercy on him) said: “whether they are standing” or bowing, or standing again after bowing, unlike other (parts of the prayer). If he is reciting the final tashahhud, then it is not Sunnah to do that, because it cannot be done except with a great deal of effort and trouble.
End quote from Tuhfat al-Habeeb ‘ala Sharh al-Khateeb (2/135)
What we have mentioned above is by way of recommendation. If they both stand beside the imam, when he is bowing or otherwise, their prayer is still valid, especially if that is easier for them or is less likely to cause confusion. Then when they rise from bowing, they may move to the preferred place.
Al-Bahooti (may Allah have mercy on him) said: If they – that is, the two people praying behind the Imam – stand with him – i.e., the imam – on his right, or they stand on either side of him, that is valid.
End quote from Kashshaaf al-Qinaa‘ (1/486)
And Allah knows best.