Person for whom the prayer is obligatory praying behind one who is offering a naafil prayer
Firstly:
There is nothing wrong with one who is offering an obligatory prayer praying behind one who is offering a naafil prayer. It is proven that Mu‘aadh ibn Jabal (may Allah be pleased with him) used to pray ‘Isha’ with the Prophet (blessings and peace of Allah be upon him), then he would go back to his people and lead them in praying ‘Isha’, and the prayer was naafil for him and obligatory for them.
It was narrated that Jaabir ibn ‘Abd-Allah (may Allah be pleased with him) said: Mu‘aadh ibn Jabal (may Allah be pleased with him) used to pray with the Prophet (blessings and peace of Allah be upon him), then he would go to his people and lead them in prayer. And he would recite al-Baqarah. … The Prophet (blessings and peace of Allah be upon him) said: “Recite ‘By the sun and its brightness’ [al-Shams 91:1], and ‘Glorify the Name of your Lord, the Most High’ [al-A’la 87:1] and the like.”
Narrated by al-Bukhaari (5755) and Muslim (465).
Al-Nawawi said:
In this hadeeth we see that it is permissible for one who is offering an obligatory prayer to pray behind one who is offering a naafil prayer, because Mu‘aadh used to offer the obligatory prayer with the Messenger of Allah (blessings and peace of Allah be upon him), so he discharged his duty, then he would pray the second time with his people, so it was voluntary for him and obligatory for them. This is stated clearly elsewhere than in Muslim, and this is permissible according to al-Shaafa‘i (may Allah have mercy on him) and others. End quote.
Sharh Muslim, 4/181
Secondly:
There is nothing wrong with a person starting his prayer alone and then becoming an imam when someone else joins him.
It was narrated that Ibn ‘Abbaas (may Allah be pleased with him) said: I stayed overnight with my maternal aunt. The Prophet (blessings and peace of Allah be upon him) got up to pray at night and I got up to pray with him. I stood on his left and he took hold of my head and made me stand on his right.
Narrated by al-Bukhaari (667) and Muslim (763).
Imam al-Bukhaari included this report in a chapter entitled: If the imam did not intend to lead others in prayer, then people join him so he leads them in prayer.
And it was narrated that Anas (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) was praying in Ramadaan, and I came and stood beside him, and another man came and stood too, until there was a group of us. When the Prophet (blessings and peace of Allah be upon him) realized that I was behind him, he made his prayer brief.
Narrated by Muslim (1104).
Some of the scholars said that it is permissible to do this in naafil prayers, but not in obligatory prayers. But the correct view is that it is valid in both cases.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
The correct view is that that is permissible in both obligatory and naafil prayers. End quote.
Majmoo‘ al-Fataawa, 22/258
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said:
But the correct view is that it is valid in both obligatory and naafil prayers. With regard to naafil prayers, it is mentioned in the text; with regard to obligatory prayers, what is proven in the case of naafil prayers is also proven with regard to obligatory prayers, unless there is evidence to the contrary.
Al-Sharh al-Mumti‘, 2/304
Thirdly:
If a person starts to pray behind a man who has started to offer a naafil prayer, as in the case asked about here, then the imam has the choice as to whether he recites out loud or quietly. But if he intended to lead the prayer from the outset, then he should recite out loud, because of the hadeeth of Mu‘aadh (may Allah be pleased with him) quoted above.
And Allah knows best.