All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
Being distracted and forgetting one’s intention during the prayer does not invalidate it. What invalidates the prayer is deliberately changing the intention or intending to change it. It is difficult to maintain one’s intention vivid in the mind throughout the entire prayer.
Abu Hurayrah reported that the Prophet, sallallaahu ‘alayhi wa sallam, said: "When the call for prayer is pronounced, Satan takes to his heels, passing wind with noise. When the call is finished, he comes back. When the Iqaamah is pronounced, he again takes to his heels and, after its completion, he returns again to interfere between the (praying) person and his heart, saying to him: 'Remember this or that thing' (things that the person could not remember before (the prayer) till he forgets whether he has offered three or four Rak‘ahs. So if one forgets whether he has prayed three or four Rak‘ahs, he should perform two prostrations of Sahw (i.e. forgetfulness)." [Al-Bukhari and Muslim]
Hence, if the change in the worshipper's intention – the way it was mentioned by the questioner – was because he was distracted or (he temporarily) forgot his intention, this does not invalidate the prayer, as stated earlier.
However, if you mean that the worshipper revoked his intention and intended to perform another prayer, then it surely invalidates the prayer as in such a case the intention totally changed.
If the questioner means that, during the prayer, he questioned his intention (and doubted whether he had intended to perform ‘Asr or Thuhr) and then counted on his doubt (without verifying it), this also invalidates the prayer as such a prayer lacks the condition of having an affirmed and assertive intention. However, if he did not act on his doubt until he realized the truth (about his specific intention), there is no harm in that.
Allaah Knows best.