The basic principle regarding the bleeding experienced by women is that it is menses (hayd), so long as it does not last for longer than fifteen days, in which case it is regarded as istihaadah (irregular bleeding) by the majority of scholars.
Some of the scholars – including Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) – are of the view that a woman is not mustahaadah (experiencing irregular bleeding) unless the bleeding lasts all month, or for most of the month.
According to the majority view, if your bleeding lasts for more than fifteen days, then anything over fifteen days is istihaadah, and in the following month you should stop praying etc. for the length of your regular cycle, which is seven days – if that was the length of your last period before the occurrence of istihaadah – then after that you should do ghusl [and resume praying etc.].
If your period used to come in the middle of the month, then you should stop praying etc. in the middle of the month.
It says in Mataalib Ooli an-Nuha (1/255-257):
If a woman who has a regular cycle experiences istihaadah, if she knows her regular cycle, the time when her menses begins and ends, and how many days it lasts, then she should stop praying etc. at that time, even if the blood looks different.
And her cycle is the duration of her menses and the duration of the time when she is “pure” (i.e., not menstruating), such as fourteen days of menses, or one day and one night, which is the minimum duration thereof, and thirteen days for the time when she is “pure”, which is the minimum duration thereof.
The second scenario is when she remembers how many days her menses usually lasted, but she has forgotten when in the (lunar) month it used to occur, but she thinks it was probably the second half of the month. In that case she should count the same number of days for her menses from when she realises her menses has started.
If she does not know how long her period lasts, because she does not know whether her menses used to come at the beginning of the month, in the middle or at the end, then she should start counting her menses from the beginning of each lunar month, on the basis that this is most likely to be the case. End quote.
Therefore, the bleeding that occurred on the second day of Ramadan was not hayd (menses), for two reasons:
Firstly: because your period comes in the middle of the month, not at the beginning.
Secondly: because there was no interval of thirteen days between it and the period that came before it, which is the minimum duration of purity between two menses.
So you did well by praying and fasting during these days.
If the bleeding did not last for longer than fifteen days, then you were not mustahaadah.
Assuming that this is the case, the bleeding that occurred on the second day of Ramadan was not menses, because there was no interval of thirteen days between it and the period that came before it. So your prayer and fasting are valid.
And Allah knows best.