The end of menses is known by one of two signs. The first is cessation of bleeding and drying up of the place, such that if a woman were to insert a piece of cotton and the like, it will come out clean with no trace of blood or yellowish or brownish discharge on it. The second sign is passing of the white discharge; some women do not see this discharge.
Passing of brownish or yellowish discharge after purification or end of the menses is not regarded as menses, so your fast is valid, because Umm ‘Atiyyah said: “We did not regard brownish or yellowish discharge after the period ended as being anything that mattered.”
Narrated by Abu Dawood (307); classed as saheeh by al-Albaani in Saheeh Abi Dawood. For more information please see the answer to question no. 50059
The fact that the questioner did ghusl and fasted on the basis that she had become pure following the end of her menses, and the fact that she forgot that, should be paid no heed, on the basis that this is what you are certain about, and so as to close the door to waswaas (whispers from the Shaytaan).
If we assume that you had been too hasty in doing ghusl and fasting, and that on that day you had not yet become pure, then you did ghusl for ‘Eid after your menses finished, but with the intention of doing ghusl for Eid, not for the end of menses, then your purification is also valid, in sha Allah, and you do not have to repeat the purification or the prayer. This is the view of the Hanbalis and this is what will make things easier for you, especially in a situation such as yours, so as to ward off waswaas and doubts concerning purification.
It says in Mataalib Ooli an-Nuha (1/111):
Whoever intends to do a Sunnah ghusl – such as ghusl for Jumu‘ah or Eid – it is valid as an obligatory ghusl, if he had forgotten (about the obligatory ghusl), to remove impurity that made ghusl obligatory. End quote.
Al-Hajjaawi (may Allah have mercy on him) said in Zaad al-Mustaqni‘: If he intended to do a Sunnah ghusl, that is valid as an obligatory ghusl. End quote.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) said:
An example is if a person does ghusl after washing a deceased person (prior to burial), or he does ghusl for ihram, or to stand in ‘Arafah. These ghusls are Sunnah. The same applies to ghusl for Jumu‘ah, according to the majority of scholars.
What the words of the author [al-Hajjaawi] appear to mean – which is also our view – is: if he remembers that he has to do an obligatory ghusl. Some of our companions limited that to the case where he forgets that he is impure or junub. If he had not forgotten, then (the obligatory ghusl) is not waived, because the Sunnah ghusl is not done to remove impurity of janaabah, and if this is the case, the Prophet (blessings and peace of Allah be upon him) said: “Actions are but by intentions”, and this man did not intend to do anything but a Sunnah ghusl, but he was aware that he was in a state of janaabah and remembered that, so how can the impurity have been removed?
This view – which limits this ruling to cases where the person has forgotten – makes a valid point.
The reasoning of the madhhab is that because the Sunnah ghusl is a prescribed means of purification, it does remove the impurity )of janaabah). But this argument is problematic, because it is undoubtedly a ghusl that is prescribed in sharee‘ah, but it is of lesser status than obligatory ghusl in the case of janaabah, so how can a Sunnah action be so strong that it can take the place of something that is obligatory and of a higher standing?
But if he had forgotten, then he is excused. For example, if a person does ghusl for Jumu‘ah on the basis that it is Sunnah, but he was in a state of janaabah, but he did not remember, or he was not aware of being in a state of janaabah until after the prayer, such as if he had a wet dream but did not realise until after the prayer, then his Jumu‘ah prayer is valid because the janaabah had been removed.
But if he knew about it and intended this ghusl to be Sunnah only, then the view that it is still valid (to remove janaabah) is something questionable.
End quote from ash-Sharh al-Mumti‘ (1/201)
From the shaykh’s words it is clear that ignorance of what makes ghusl obligatory comes under the same ruling as forgetting, so his purification by means of a mustahabb ghusl is valid.
And Allah knows best.