Praise be to Allah.
Whatever the case, the Sunnah is to pray Taraweeh after ‘Isha’, so the qiyaam of Ramadan comes after ‘Isha’, but this is naafil, so his praying it with them before ‘Isha’ is regarded as a naafil prayer between Maghrib and ‘Isha’, and praying between Maghrib and ‘Isha’ is permissible, but it does not count as the qiyaam that is well known in Ramadan. The qiyaam of Ramadan comes after ‘Isha’. So this is regarded as a naafil prayer that he did between Maghrib and ‘Isha’, and his praying ‘Isha’ after that is valid. But what is preferable and better is to start with the obligatory prayer, then pray Taraweeh with them. This is what should be done so as to follow the Sunnah as well as performing the obligatory prayer.
If he prayed with them with the intention of offering the obligatory prayer, then when the imam said the salaam at the end of (the two rak‘ahs of) Taraweeh, then he stood up and completed the obligatory prayer, that would have been acceptable. So if the imam prayed the first two rak‘ahs with the intention of praying Taraweeh, and he was offering the obligatory prayer, then when the imam said the salaam, he stood up and completed his prayer, that would be acceptable.
To sum up: there is nothing wrong with this, in sha Allah; his prayer is valid, and his Taraweeh is valid, but it is regarded as naafil. It is not Taraweeh and it is not the well known qiyaam of Ramadaan; rather the qiyaam of Ramadan comes after ‘Isha’. But what he prayed came before ‘Isha’, so it comes under the heading of the naafil prayers which it is mustahabb to offer between Maghrib and ‘Isha’.
Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allah have mercy on him)
Fataawa Noor ‘ala al-Darb, 2/903