It's a recursive algorithm, meaning that it calls itself to accomplish smaller parts of the whole process.
Flood fill will start at one pixel. Then it will check the four adjacent pixels (up, down, left, right). For any of those four pixels that are the same colour as the one we started with, it will call another flood fill starting from that pixel.
Imagine a small picture where . is one colour, and X is another colour. The numbers are just there for reference, so 7,0 is the top right. (Ignore the red / black syntax hilighting!)
01234567
0........
1.XXXX...
2.X..X...
3.X...X..
4.XXX..X.
5...X..X.
6...XXX..
7........
Now imagine you start a flood fill at 3,3. It will change 3,3 to the new colour.
It will then check up,down,left,right.
For up (3,2), the colour there is the same (a dot), so it will start another flood fill from there.
For down (3,4), the colour is different, so this branch will stop.
Left, (2,3), and right (4,3) are also the same (a dot), so more branches of flood fill start from there.
Let's say that new colour is O, so we now have this:
01234567
0........
1.XXXX...
2.X.OX...
3.XOOOX..
4.XXX..X.
5...X..X.
6...XXX..
7........
The "up" branch started a new flood fill from (3,2).
From here, up is X, so that stops. Right is X, so that stops, down is O, so that stops, but left (2,2) is the same (a dot), so it starts a new flood fill from there.
Similarly, the "right" branch from the original flood fill began from (4,3). The only branch it can use is down (4,4). Now we have this:
01234567
0........
1.XXXX...
2.XOOX...
3.XOOOX..
4.XXXO.X.
5...X..X.
6...XXX..
7........
And so the flood fill continues from (4,4), by branching right and down. One of those two branches will then branch into (5,5). By that time, there will be no further possible branches.
And that is my lunchtime filled :)