You should put comments in the code to say what each section does turn left turn right and so on.
You should also put print statements so that as you watch the follower you can keep one eye on the output to see what it is doing and why.
Your program really has only four input states;
BLACK BLACK
WHITE WHITE
BLACK WHITE
WHITE BLACK
and it has four fixed responses to these inputs.
It has no memory, it does not know what it was doing last or how long it was doing it for.
That is what is causing your oscillations.
If the follower has been BLACK BLACK for a long time it must be going fast along a straight.
If it then goes WHITE BLACK then either it is on the straight and drifting of it to the left or it has reached a right hand bend. It should make a small turn to the right. If that gets it back to BLACK BLACK then it was drifting off the line and it should start going straight again. On the other hand if it continues to be WHITE BLACK then it must be on a corner and it needs to make a sharper right turn. If it quickly goes WHITE BLACK, BLACK BLACK, BLACK WHITE it turned too quickly.
So you need to build some memory and timing into your program.
If the track is fixed and you are allowed to know the layout then after a few trials you could more or less hard code the speed of turning the follower needs to make to get round the corner, however that is cheating and not really following the line.