LED blinking as much as button counter

Please explain me how this code works…

const int switchPin=2;
const int ledPin=13;
int state=0;
int lastState=0;
int count=0;
unsigned long a=0; 
const long b=1000; 

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(switchPin, INPUT);
}

void loop() {
  state=digitalRead(switchPin);
  if(state!=lastState){
    if(state==HIGH){
      count++;
      a=millis();     
    }
    lastState=state;
  }
  if(a+b<millis()){
    switch(count){
      case 1:
      digitalWrite(ledPin, HIGH);
      delay(200);
      digitalWrite(ledPin, LOW);
      delay(200);
      break;
      case 2:
      for(int i=0;i<2;i++){
        digitalWrite(ledPin, HIGH);
        delay(200);
        digitalWrite(ledPin, LOW);
        delay(200);
      }
      break;
      case 3:
      for(int i=0;i<3;i++){
        digitalWrite(ledPin, HIGH);
        delay(200);
        digitalWrite(ledPin, LOW);
        delay(200);
      }
      break;
      case 4:
      for(int i=0;i<4;i++){
        digitalWrite(ledPin, HIGH);
        delay(200);
        digitalWrite(ledPin, LOW);
        delay(200);
      }
      break;
      case 5:
      for(int i=0;i<5;i++){
        digitalWrite(ledPin, HIGH);
        delay(200);
        digitalWrite(ledPin, LOW);
        delay(200);
      }
    }
    count=0;
  }
  delay(20);
}

Thanks

That question is too broad.

Where did you get the sketch?

What part of the sketch are you not understanding?

What is not working for you?

The code sets ledPin HIGH and then later LOW and then does it again. That's why the LED is blinking.

Steve