If someone comes late to the prayer and wants to join another person in prayer, or there are only one person praying behind the Imam, where should that person stand behind the Imam?
If there is an Imam, with only one person praying with him, he should stand at the right side of the Imam.
Ibn `Abbas (may Allah be pleased with him) narrated: Once I passed the night in the house of my aunt Maymunah (the wife of the Prophet, may Allah be pleased with her). The Prophet (peace be upon him) stood for the night prayer and I joined him and stood on his left side but he drew me to his right by holding me by the head.” (Al-Bukhari)
In another hadith, Ibn `Abbas said: “I came to the Messenger of Allah (peace be upon him) at the end of the night and prayed behind him. He took my hand and drew me to stand in line with him, and when the Messenger of Allah (peace be upon him) turned back to his prayer, I took a step backwards. The Messenger of Allah (peace be upon him) prayed, and when he finished his prayer, he said to me, ‘What is the matter? I made you stand in line with me, then you took a step backwards.’ I said, ‘O Messenger of Allah, is it right for anyone to pray in line with you when you are the Messenger of Allah to whom Allah has given …?’ (Imam Ahmad)
To know more about the rulings of how the praying person should stand with the Imam in congregational prayer, watch this interesting talk with Dr. Muhammad Salah.
Source: Huda Youtube Channel.