Praise be to Allah.
Whoever prays when he is not in a state of tahaarah (purity) has to purify himself and repeat the prayer, according to scholarly consensus, even if he forgot. Al-Nawawi said in al-Majmoo’ (2/78):
The Muslims are unanimously agreed that it is haraam to pray when one is impure, and they are unanimously agreed that the prayer is not valid whether he knew that he was impure or was unaware of it or forgot. But if he prayed not knowing it or having forgotten it, there is no sin on him; if he knew that he was impure and that it is haraam to pray when one is impure, then he has committed a grave sin.
Ghusl following janaabah is not valid unless one has the intention of doing ghusl, because the Prophet (peace and blessings of Allaah be upon him) said: “Actions are but by intentions.” Narrated by al-Bukhaari, 1; Muslim, 1907.
The site of the intention is the heart; it is not required to speak it out loud.
If you remembered that you were in a state of janaabah before you took a bath at Maghrib time, and you took a bath for that reason and repeated the prayers that you had offered when you were junub, then that ghusl is valid because the intention was there. You did well to repeat the prayers as this is what is required of you.
But if you did not remember that you were in a state of janaabah until after you had had the bath, and you took a bath in order to clean yourself or to cool yourself down, for example, then this bath did not take away the janaabah because there was no intention to do so. In that case you have to repeat the ghusl and the prayers. You repeated the ghusl, so all that remains for you to do is to repeat the prayers. So repeat Fajr, Zuhr, ‘Asr and Maghrib.
And Allaah knows best.