Praise be to Allah.
Taraweeh prayer is qiyaam al-layl (night prayers) in Ramadan, and there is no set number of rak‘ahs for qiyaam al-layl in Ramadan or at any other time, that the Muslim should not exceed. So he may pray as much as he wants at night in Ramadan and otherwise.
If the people at the mosque divide the night prayers in Ramadan into two parts, one part after ‘Isha’ and another part at the end of the night, in order to attain the virtue of praying at the time before dawn and to strive hard in worship, especially in the last ten nights, and they do Witr at the end of the prayer, there is nothing wrong with them doing that.
The scholars of the Standing Committee for Issuing Fatwas said:
There is nothing wrong with increasing the number of rak‘ahs during the last ten nights and doing more than in the first twenty nights, and dividing them into two parts, one that is prayed at the beginning of the night and made brief like Taraweeh in the first twenty nights, and another part that is prayed at the end of the night and made lengthy like tahajjud. The Prophet (blessings and peace of Allah be upon him) used to strive hard in worship in the last ten nights in a manner unlike other times.
End quote from Fataawa al-Lajnah ad-Daa’imah – vol 2 (6/82)
If a person prays Taraweeh in one mosque, then he finds another mosque where prayers are still going on, and he goes and prays with the people, there is nothing wrong with him doing that either, but he should not pray Witr twice. So if he prayed Witr with the first congregation, he should not pray Witr with the second congregation, because there should not be two Witrs in one night.
For example, if he is an imam who leads the people in prayer in two mosques, or who leads two different groups in prayer, at the beginning of the night and at the end of the night, or he prays as a member of the congregation in one and as an imam leading the prayer in the other, all of that is permissible and there is nothing wrong with it, in sha Allah.it was narrated by Abu Dawood (1439), at-Tirmidhi (470), an-Nasaa’i (1679) and Ahmad (16296) from Qays ibn Talq who said: Talq ibn ‘Ali visited us one day in Ramadan, and he stayed with us until the evening and broke his fast, then he led us in praying the night prayers and led us in praying Witr. Then he went to his own mosque, and led his companions in prayer, then when only Witr was left, he asked a man to go forward and lead the prayer, and said: Lead your companions in praying Witr, for I heard the Prophet (blessings and peace of Allah be upon him) say: “There should not be two Witrs in one night.” This hadith was classed as hasan by Ibn al-Mulaqqin in al-Badr al-Muneer (4/317) and by al-Haafiz in al-Fath (2/481). It was classed as hasan by the commentators on al-Musnad, and as saheeh by al-Albaani in Saheeh Sunan Abi Dawood.
As-Sindi (may Allah have mercy on him) said:
“So he led his companions in prayer” – what appears to be the case is that he led them in both the obligatory and supererogatory prayer, so the people followed him in offering the obligatory prayer by way of one who is offering an obligatory prayer following one who is offering a supererogatory prayer.
End quote from Haashiyat as-Sindi ‘ala Sunan an-Nasaa’i (3/230)
Imam Ahmad was asked about a man who leads people in ‘Isha’ and Taraweeh prayers during the month of Ramadan – can he lead them in praying Witr when he intends to lead another group in prayer after that? He (may Allah have mercy on him) said: He should do something in between, such as eating, drinking, or sitting down.
Narrated by al-Mirwazi.
Ibn al-Qayyim (may Allah have mercy on him) said:
That is because it is makrooh to follow Witr immediately with another prayer. So he should do something else in between, so that there will be an interval between his Witr and subsequent prayers. This applies if he is going to lead them in prayer in the same place. But if it is going to be in another place, then his going there will form a separation. But he should not do a second Witr, because “There should not be two Witrs in one night.”
End quote from Badaa’i‘ al-Fawaa’id (4/111)
Most of the fuqaha’ are of the view that doing this is permissible in all cases, and is not makrooh in any situation.
See: Fath al-Baari by Ibn Rajab (6/258-259)
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said:
If you have prayed Witr in your own mosque, then you go to another mosque and find the people praying there, then go in and pray with them, but when they pray Witr, stand up and add another rak‘ah so that the prayer will be even-numbered, because you have already prayed Witr.
End quote from Jalasaat Ramadaniyyah
For more information, please see the answer to question no. 20851
And Allah knows best.