وَإِنْ عَلِمَ ذَلِكَ وَهُوَ فِي الصَّلَاةِ اسْتَدَارَ إِلَى الْقِبْلَةِ وَبَنَى عَلَيْهَا
Translation: If he learns of the error while in prayer, he turns toward the qiblah and continues that prayer.
Istadara means turning to the correct direction; bana 'alayha means continuing on what has already been performed rather than starting anew.
Once the accurate direction becomes known during prayer, the earlier uncertainty ends and the worshipper must turn accordingly.