May i know how to combine this coding?

my system is about UV led disinfection. when power on the display should show "UV LED disinfection". then there will be a door sensor to detect the door condition and the LCD display the door is closed or open. after that, when the door is closed we press the button to select mode between mode 1 or mode 2. but when I run the coding the "UV LED disinfection" do not display and the "door closed" is show directly and when pressed button cannot select mode.

#include <LiquidCrystal_I2C.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x27,16,2);
int motorSwitchAA = 12;
int pwmPinAA = 10;
int doorState;
int buzzer =4;
int button=10;
const int DOOR_SENSOR_PIN =13;
int led=11;

int ledState=LOW;
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;    // the debounce time; increase if the output flickers



void setup() {
  lcd.begin();
  lcd.backlight();
  Serial.begin(9600);                     // initialize serial
  pinMode(DOOR_SENSOR_PIN, INPUT_PULLUP); // set arduino pin to input pull-up mode
  analogWrite(pwmPinAA,0);
  digitalWrite(motorSwitchAA,LOW);
  pinMode(button,OUTPUT);
  pinMode(led,OUTPUT);
  digitalWrite(led,ledState);
}

void loop() {
  doorState = digitalRead(DOOR_SENSOR_PIN); // read state

  if (doorState == LOW) {
    analogWrite(pwmPinAA, 0);
    digitalWrite(motorSwitchAA, LOW);
    //Serial.println("The door is closed");
    
    lcd.setCursor(0,0);
    lcd.print("The door");
    lcd.setCursor(7,1);
    lcd.print("is closed");
   noTone(buzzer);

   int reading = digitalRead(button);
   if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
     if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState) {
      buttonState = reading;

      // only toggle the LED if the new button state is HIGH
      if (buttonState == HIGH) {
        
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Press x1->Mode 1");
    lcd.setCursor(0,1);
    lcd.print("Press x2->Mode 2");
      ledState = !ledState;
      
    }
    
  }


   }

  // set the LED:
  digitalWrite(led, ledState);
  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:
 lastButtonState = reading;
  }   

  }
  else {
    
    analogWrite(pwmPinAA, 0);
    digitalWrite(motorSwitchAA,HIGH);

    //Serial.println("The door is open");
    
    lcd.setCursor(0,0);
    lcd.print("The door");
    lcd.setCursor(7,1);
    lcd.print("is opened");
    
    tone(4,440);
   }
   }

Hello
If you can than post your sketch in so called code tags "</>".

#include <LiquidCrystal_I2C.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x27,16,2);
int motorSwitchAA = 12;
int pwmPinAA = 10;
int doorState;
int buzzer =4;
int button=10;
const int DOOR_SENSOR_PIN =13;
int led=11;

int ledState=LOW;
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;    // the debounce time; increase if the output flickers



void setup() {
  lcd.begin();
  lcd.backlight();
  Serial.begin(9600);                     // initialize serial
  pinMode(DOOR_SENSOR_PIN, INPUT_PULLUP); // set arduino pin to input pull-up mode
  analogWrite(pwmPinAA,0);
  digitalWrite(motorSwitchAA,LOW);
  pinMode(button,OUTPUT);
  pinMode(led,OUTPUT);
  digitalWrite(led,ledState);
}

void loop() {
  doorState = digitalRead(DOOR_SENSOR_PIN); // read state

  if (doorState == LOW) {
    analogWrite(pwmPinAA, 0);
    digitalWrite(motorSwitchAA, LOW);
    //Serial.println("The door is closed");
    
    lcd.setCursor(0,0);
    lcd.print("The door");
    lcd.setCursor(7,1);
    lcd.print("is closed");
   noTone(buzzer);

   int reading = digitalRead(button);
   if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
     if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState) {
      buttonState = reading;

      // only toggle the LED if the new button state is HIGH
      if (buttonState == HIGH) {
        
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Press x1->Mode 1");
    lcd.setCursor(0,1);
    lcd.print("Press x2->Mode 2");
      ledState = !ledState;
      
    }
    
  }


   }

  // set the LED:
  digitalWrite(led, ledState);
  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:
 lastButtonState = reading;
  }   

  }
  else {
    
    analogWrite(pwmPinAA, 0);
    digitalWrite(motorSwitchAA,HIGH);

    //Serial.println("The door is open");
    
    lcd.setCursor(0,0);
    lcd.print("The door");
    lcd.setCursor(7,1);
    lcd.print("is opened");
    
    tone(4,440);
   }
   }

What LCD library are you using?

i2c lcd

No where in the posted sketch is this coded ????

I'm sorry what do you mean?

Read your own explanation in your post

I corrected the logic for the debounce

#include <LiquidCrystal_I2C.h>
//#include <Wire.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);
int motorSwitchAA = 12;
int pwmPinAA = 10;
int doorState;
int buzzer = 4;
int button = 10;
const int DOOR_SENSOR_PIN = 13;
int led = 11;

int ledState = LOW;
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;    // the debounce time; increase if the output flickers



void setup() {
  lcd.begin();
  lcd.backlight();
  Serial.begin(9600);                     // initialize serial
  pinMode(DOOR_SENSOR_PIN, INPUT_PULLUP); // set arduino pin to input pull-up mode
  analogWrite(pwmPinAA, 0);
  digitalWrite(motorSwitchAA, LOW);
  pinMode(button, OUTPUT);
  pinMode(led, OUTPUT);
  digitalWrite(led, ledState);
}

void loop() {
  doorState = digitalRead(DOOR_SENSOR_PIN); // read state

  if (doorState == LOW) {
    analogWrite(pwmPinAA, 0);
    digitalWrite(motorSwitchAA, LOW);
    //Serial.println("The door is closed");

    lcd.setCursor(0, 0);
    lcd.print("The door");
    lcd.setCursor(7, 1);
    lcd.print("is closed");
    noTone(buzzer);

    int reading = digitalRead(button);
    if (reading != lastButtonState) {
      // reset the debouncing timer
      lastDebounceTime = millis();
      // save the reading.  Next time through the loop,
      lastButtonState = reading;
    }
    if ((millis() - lastDebounceTime) > debounceDelay) {
      // whatever the reading is at, it's been there for longer
      // than the debounce delay, so take it as the actual current state:

      // if the button state has changed:
      if (reading != buttonState) {
        buttonState = reading;

        // only toggle the LED if the new button state is HIGH
        if (buttonState == HIGH) {
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("Press x1->Mode 1");
          lcd.setCursor(0, 1);
          lcd.print("Press x2->Mode 2");
          ledState = !ledState;
        }
      }
    }
    // set the LED:
    digitalWrite(led, ledState);
  }
  else {

    analogWrite(pwmPinAA, 0);
    digitalWrite(motorSwitchAA, HIGH);

    //Serial.println("The door is open");

    lcd.setCursor(0, 0);
    lcd.print("The door");
    lcd.setCursor(7, 1);
    lcd.print("is opened");

    tone(4, 440);
  }
}

The reason for the question is the "LiquidCrystal_I2C" library is somewhat obsolete and you appear to be quite fortunate that the display you are using actually matches the old library and shows anything at all. Generally, you need to use the "HD44780" library available in the IDE.