Arduino suddenly working without delay

I'm working on automatic planting system where the a pump will supply water when the humidity of the sand are low. In this project, I'm also using ultrasonic sensor to control the water inside the tank. Once the tank already reach its minimum water level, a buzzer will ring. However, the system seems only can running properly (with delay) in a few minutes. After that, the system suddenly has no delay which make the serial monitor prints the output too fast (without delay). It's that the problem coming from the arduino board itself of my codes?

Here is the code:

int water; //random variable 
const int TRIG_PIN   = 9; // Arduino pin connected to Ultrasonic Sensor's TRIG pin
const int ECHO_PIN   = 10; // Arduino pin connected to Ultrasonic Sensor's ECHO pin
const int BUZZER_PIN = 13; // Arduino pin connected to Piezo Buzzer's pin
const int DISTANCE_THRESHOLD = 20; // centimeters
float duration_us, distance_cm;

void setup(){
  Serial.begin(9600);
  pinMode(3,OUTPUT); //output pin for relay board, this will sent signal to the relay
  pinMode(6,INPUT); //input pin coming from soil sensor
  pinMode(TRIG_PIN, OUTPUT);   // set arduino pin to output mode
  pinMode(ECHO_PIN, INPUT);    // set arduino pin to input mode
  pinMode(BUZZER_PIN, OUTPUT);
}

void loop() { 
  water = digitalRead(6);  // reading the coming signal from the soil sensor
  Serial.print(F("Water Level = "));
  Serial.println(water);

  if(water == 10) // if water level is full then cut the relay 
  {
  digitalWrite(3,LOW); // low is to cut the relay
  }
  else
  {
  digitalWrite(3,LOW); //high to continue proving signal and water supply
  }

  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW); // measure duration of pulse from ECHO pin
  duration_us = pulseIn(ECHO_PIN, HIGH); // calculate the distance
  distance_cm = 0.017 * duration_us;

  Serial.print("distance: ");
  Serial.print(distance_cm);
  Serial.println(" cm");

  if(distance_cm > DISTANCE_THRESHOLD)
    {
digitalWrite(BUZZER_PIN, HIGH);
delay(800);
digitalWrite(BUZZER_PIN, LOW);
}
  else
  { digitalWrite(BUZZER_PIN, LOW);  // turn off Piezo Buzzer
  }
delay(800);
}


You are using LOW for both conditions.

Can you please clarify what you mean by system running properly?

for who is serial output? is someone in greenhouse near and read messages with computer?
i mean you can delete any serial instructions and problem disappear.

  int water = digitalRead(6);  // reading the coming signal from the soil sensor
  if (water < 11)digitalWrite(3, LOW); // low is to cut the relay // if water level is full then cut the relay

is soil sensor digital or analog?
where is it connected, to digital pin or to analog?
should it be analogRead or digitalRead?

const int TRIG_PIN   = 9; // Arduino pin connected to Ultrasonic Sensor's TRIG pin
const int ECHO_PIN   = 10; // Arduino pin connected to Ultrasonic Sensor's ECHO pin
const int BUZZER_PIN = 13; // Arduino pin connected to Piezo Buzzer's pin
const int DISTANCE_THRESHOLD = 20; // centimeters

void setup() {
  Serial.begin(9600);
  pinMode(3, OUTPUT); //output pin for relay board, this will sent signal to the relay
  pinMode(6, INPUT); //input pin coming from soil sensor
  pinMode(TRIG_PIN, OUTPUT);   // set arduino pin to output mode
  pinMode(ECHO_PIN, INPUT);    // set arduino pin to input mode
  pinMode(BUZZER_PIN, OUTPUT);
}

void loop() {
  if (analogRead(A0) < 11)digitalWrite(3, LOW); // low is to cut the relay // if water level is full then cut the relay
  else digitalWrite(3, HIGH); //high to continue proving signal and water supply


  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW); // measure duration of pulse from ECHO pin
  int distance_cm = pulseIn(ECHO_PIN, HIGH) / 58; // calculate the distance

  if (distance_cm > DISTANCE_THRESHOLD)  {
    digitalWrite(BUZZER_PIN, HIGH);
    delay(800);
    digitalWrite(BUZZER_PIN, LOW);
  }
  else   digitalWrite(BUZZER_PIN, LOW);  // turn off Piezo Buzzer

  delay(800);
}

Please edit your post and present the code after pretty formatting by the IDE (CTRL-T for Auto Format).

@khaiaz - Here is a simulation where you can see that your code runs well. I made minor adjustments to make the simulation readable.

Thank you guys, the problem has been solved. I changed to a new and everything works fine.