If a person wants to recite Sūrat al-Ḥamd in the third or fourth rakʿahs but happens to say al‑tasbīḥāt al‑arbaʿah instead, or if one wants to say al‑tasbīḥāt al‑arbaʿah but happens to recite Sūrat al-Ḥamd instead, then in the event that he did not have the intention of prayers at all, not even subconsciously, he must leave whatever it was he was saying and recite Sūrat al-Ḥamd or say al‑tasbīḥāt al‑arbaʿah again.
However, if it was not the case that he did not have the intention of prayers, rather it was his habit to say that thing, then he can complete what he was saying and his prayer will be valid.