Praise be to Allah.
Qiyaam and Witr can only be prayed after praying ‘Isha’. So you should have prayed ‘Isha’ first and then prayed qiyaam and Witr after that.
Al-Nawawi said in al-Majmoo’ (3/526):
The time for Taraweeh begins when ‘Isha’ prayer is over, as was stated by al-Baghawi and others, and lasts until dawn comes. End quote.
It says in al-Insaaf (4/166):
The time for it (i.e., Taraweeh) begins after ‘Isha’ prayer and its Sunnahs, according to the correct view. This is the view of the majority and is the practice of the Muslims. End quote.
Shaykh Ibn ‘Uthaymeen said:
The time for Taraweeh is from after ‘Isha’ prayer until dawn comes. End quote.
Majmoo’ Fataawa Ibn ‘Uthaymeen, 14/210
Based on this, what should a person do if he comes to the mosque late, when the imam has already finished ‘Isha’ and has started Taraweeh?
The correct view is that he should join the imam, with the intention of praying ‘Isha’, and he should stand to complete his prayer (i.e., four rak’ahs) after the imam says the salaam. Then he should join him in the remainder of Taraweeh prayer.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) said:
There is nothing wrong with praying ‘Isha’ behind one who is praying Taraweeh. Imam Ahmad (may Allaah have mercy on him) stated that if a man enters the mosque in Ramadaan when they are praying Taraweeh, he should pray behind the imam with the intention of praying ‘Isha’, then when the imam says the salaam at the end of the prayer, he should complete whatever remains of ‘Isha’ prayer.
End quote from Majmoo’ Fataawa Ibn ‘Uthaymeen, 12/443, 445
See also the answer to question no. 37829 for more information of praying Taraweeh before ‘Isha’.
And Allaah knows best.