Assalamu’alaikum warahmatullahi wabarakatuh,
IN THE NAME OF ALLAH, THE MOST BENEFICENT, THE MOST MERCIFUL
Firstly: Whoever prays when he or she 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.
Secondly: Ghusl following janaabah is not valid unless one has the intention of doing ghusl, because the Prophet (peace and blessings of Allah 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 she remembered that she was in a state of janaabah before she took a bath at Maghrib time, and she took a bath for that reason and repeated the prayers that she had offered when she was in the state of junub, then that ghusl is valid because the intention was there. she did well to repeat the prayers as this is what is required of her.
But if she did not remember that she was in a state of janaabah until after she had the bath, and she took a bath in order to clean herself or to cool herself down, for example, then this bath did not take away the janaabah because there was no intention to do so. In that case she have to repeat the ghusl and the prayers. she repeated the ghusl, so all that remains for her to do is to repeat the prayers.
Allah knows best.