Can You Pray While in the State of Janabah?
Question

My paternal uncle died, and I was told about his death, so I quickly travelled to the scene of the accident, covering a distance of 90 km, when I was in the state of Janabah. I reached the place, and was unable to find water, so I did Tayammum and washed him, and we came back to the village for the burial and reached the mosque. The weather was extremely cold, so I forgot that I had done Tayammum, and I went in and did Wudu, then I prayed Fajr, after which we offered the funeral prayer then we went to the burial. I went down into his grave and put him in the niche, and I did not pay attention to anything because I was extremely exhausted. One year after that, I remembered what had happened. Is my prayer valid? And is there any sin on me?
Praise be to Allah.When Tayammum is Allowed for Janabah
Tayammum is prescribed for one who cannot find water, or who can find water but cannot use it because of illness  , or fears to become ill.
Based on that, if you did Tayammum  because there was no water available, then your Tayammum was valid, but its validity is temporary and lasts only until the excuse for doing it no longer applies. When you entered the village, the excuse was no longer applicable, because water was available and it was possible to heat it. So when you prayed Fajr, you did so without being in a state of purity, because you prayed when you were in a state of Janabah (a state of ritual impurity caused by the discharge of semen or sexual intercourse).
Therefore, you have to repeat that prayer, but there is no sin on you for that, because you did not deliberately pray in a state of Janabah. Allah, may He be Exalted, says (interpretation of the meaning): {And there is no blame upon you for that in which you have erred but [only for] what your hearts intended.} [Al-Ahzab 33:5]
What Happens If You Pray While in the state of Janabah?
An-Nawawi (may Allah have mercy on him) said:
The scholars unanimously agreed that it is forbidden for one who is in a state of impurity to pray , and they unanimously agreed that such a prayer is not valid, regardless of whether he knew that he was in a state of impurity, or he was unaware of that, or he forgot. However, if he prayed out of ignorance or he forgot, there is no sin on him. (End quote from Al-Majmu`, 2/67)
What to do if one Prayered While in a State of Janabah?
Shaykh Al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
If someone forgets to purify himself from impurity and prays in that state, then he must repeat the prayer after purifying himself, and there is no difference of scholarly opinion concerning that. (End quote from Majmu`  Al-Fatawa, 22/99)
Shaykh `Abd Al-`Aziz ibn Baz (may Allah have mercy on him) said:
If someone prays thinking that he has Wudu, then he realises that he prayed without Wudu, is his prayer valid or does he have to repeat it?
He replied:
If someone prays, believing or thinking that he has Wudu ,  then he realises that he does not have Wudu, he has to repeat the prayer, because the Prophet (blessings and peace of Allah be upon him) said: “Allah does not accept any prayer without [the worshipper] having purified himself [beforehand].” And he (blessings and peace of Allah be upon him) said: “Allah does not accept the prayer of any one of you if he is in a state of impurity, until he does Wudu.”
This is according to the consensus of the Muslims. If a person prays then realises that he did not have Wudu, then he must do Wudu and repeat his prayer. (End quote from Fatawa Nur `ala Ad-Darb, 7/229)
He was also asked:
I remembered that I once prayed without Wudu; should I repeat that prayer?
He replied:
Yes, you must repeat it , according to the consensus of the Muslims, because the Prophet (blessings and peace of Allah be upon him) said: “Allah does not accept any prayer without [the worshipper] having purified himself [beforehand].” (Narrated by Muslim). And he (blessings and peace of Allah be upon him) said: “Allah does not accept the prayer of any one of you if he is in a state of impurity, until he does Wudu.” (Narrated by Al-Bukhari and Muslim) (End quote from Fatawa Nur `ala Ad-Darb, 7/230-231)
You are not regarded as having sinned, because doing things by mistake or forgetting are reasons for which a person is excused.
And Allah knows best.