lcd display flickering on every loop() cycle

hello, i made a gas detector using mq sensor and i attached the output of the sensor to a lcd display 20x4, now im trying to polish a bit the code adding fancy decorations and shit.

the problem is that each loop my lcd executes the begin function and flickers on and off the backlight for an instant. i tried solving this by putting the lcd.begin(20, 4); instruction on the setup() but it seems that makes the lcd unable to update new information, not sure why.
then i fixed it by putting the begin function on the loop cycle but that seems to make the lcd flickers everytime the loop cycle ends (the flickering is every 5 seconds that is the delay of the sensor scan and the total time of the loop duration, if i change the delay it changes the flickering ratio at exactly the same speed of the delay)

i would like to know why the lcd is flickering even when the backlighting is hardwired in the setup loop, and how to fix it, the information printed is perfectly fine and has no problem whatsoever.

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

int SogliaSensore = 500;
int PinLedRosso = 2;
int PinLedBlu = 4;
int PinLedVerde = 7;
int Buzzer = 8;
int Timer = 5;
LiquidCrystal_I2C lcd (0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup() {
  pinMode (3, OUTPUT);
  digitalWrite(3, 10);
  pinMode (A4, OUTPUT);
  pinMode (A5, OUTPUT);
  pinMode (PinLedRosso, OUTPUT);
  pinMode (PinLedBlu, OUTPUT);
  pinMode (PinLedVerde, OUTPUT);
  pinMode (Buzzer, OUTPUT);
  pinMode (A3, INPUT);
  Serial.begin(9600);
}

void loop() {
lcd.begin(20, 4);
lcd.setCursor(0, 0);
int SensorValue = analogRead (A3);
if (SensorValue < SogliaSensore) {
Serial.print("Sensor: Gas Quantity Detected is Safe!   ");
Serial.println (SensorValue);
lcd.print("Gas Quantity");
lcd.setCursor(0,1);
lcd.print("Detected");
lcd.setCursor(0,2);
lcd.print("is Safe");
lcd.setCursor(0,3);
lcd.print(SensorValue);
digitalWrite (Buzzer, LOW);
RGB_controller (LOW, LOW, HIGH);
}
  else
  { 
    
 RGB_controller (HIGH, LOW, LOW);
 Serial.print ("Sensor: WARNING! Gas Quantity Detected is Harmful! ");
Serial.println (SensorValue);
lcd.print("Warning: Gas");
lcd.setCursor(0,1);
lcd.print("Quantity Detected");
lcd.setCursor(0,2);
lcd.print("is Harmful!");
lcd.setCursor(0,3);
lcd.print(SensorValue);
digitalWrite (Buzzer, HIGH);
Timer = 2;
SensorValue = analogRead (A3) - Timer;
  }
  delay(5000);
}

void RGB_controller (int Luminosita_rosso, int Luminosita_blu, int Luminosita_verde) {
digitalWrite (PinLedRosso, Luminosita_rosso);
digitalWrite (PinLedBlu, Luminosita_blu);
digitalWrite (PinLedVerde, Luminosita_verde);
}

thanks in advance, alberto.

You only need to call lcd.begin() one time. Call it in setup().

Don't use delay() for timing, use millis() instead.
Non-blocking timing tutorials:
Several things at a time.
Beginner's guide to millis().
Blink without delay().

hello, that didn't help.
when i call it in setup() the lcd screen becomes stuck on the latest info it was printed into it and doesnt change anymore.

If you make changes to your code please post the latest version so that we do not have to guess what you have done.

this is the latest version of the code, im now stuck on an empty lcd screen and only the backlighting is working

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

int SogliaSensore = 500;
int PinLedRosso = 2;
int PinLedBlu = 4;
int PinLedVerde = 7;
int Buzzer = 8;
int Timer = 5;
LiquidCrystal_I2C lcd1 (0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup() {
  pinMode (3, OUTPUT);
  digitalWrite(3, HIGH);
  pinMode (A4, OUTPUT);
  pinMode (A5, OUTPUT);
  pinMode (PinLedRosso, OUTPUT);
  pinMode (PinLedBlu, OUTPUT);
  pinMode (PinLedVerde, OUTPUT);
  pinMode (Buzzer, OUTPUT);
  pinMode (A2, INPUT);
  pinMode (A3, INPUT);
  Serial.begin(9600);
  lcd1.begin(20,4);
}

void loop() {
int SensorValue_2 = analogRead (A2);
int SensorValue_135 = analogRead (A3);
if (SensorValue_2 < SogliaSensore && SensorValue_135 < SogliaSensore) {
Serial.print("Sensor: Gas Quantity Detected is Safe!   ");
Serial.println (SensorValue_2, SensorValue_135);
lcd1.print("Gas Quantity is Safe");
lcd1.setCursor(0,1);
lcd1.print("Concentration Data:");
lcd1.setCursor(0,2);
lcd1.print("MQ-2:    ");
lcd1.print(SensorValue_2);
lcd1.print(" PPM");
lcd1.setCursor(0,3);
lcd1.print("MQ-135:  ");
lcd1.print(SensorValue_135);
lcd1.print(" PPM");
digitalWrite (Buzzer, LOW);
RGB_controller (LOW, LOW, HIGH);
}
  else
  { 
    
 RGB_controller (HIGH, LOW, LOW);
 Serial.print ("Sensor: WARNING! Gas Quantity Detected is Harmful! ");
Serial.println (SensorValue_135);
lcd1.print("Harmful Gas Detected");
lcd1.setCursor(0,1);
lcd1.print("Concentration Data:");
lcd1.setCursor(0,2);
lcd1.print("MQ-2:    ");
lcd1.print(SensorValue_2);
lcd1.print(" PPM");
lcd1.setCursor(0,3);
lcd1.print("MQ-135:  ");
lcd1.print(SensorValue_135);
lcd1.print(" PPM");
digitalWrite (Buzzer, HIGH);
Timer = 2;
SensorValue_135 = analogRead (A3) - Timer;
SensorValue_2 = analogRead (A2) - Timer;
  }
  delay(5000);
}

void RGB_controller (int Luminosita_rosso, int Luminosita_blu, int Luminosita_verde) {
digitalWrite (PinLedRosso, Luminosita_rosso);
digitalWrite (PinLedBlu, Luminosita_blu);
digitalWrite (PinLedVerde, Luminosita_verde);
}

if i switch the lcd1.begin into the loop function it works perfectly but blinks the backlighting each time it completes the loop, if i write lcd1.begin into the setup function the lcd becomes unable to print updates and gets stuck.

I suggest that you work with the examples that come with the LiquidCrystal_I2C library that you are using to get a good understanding of how the library works before adding in the rest of the code.

And look for LCD tutorials like this one.

There is no need to include this library.

#include <LCD03.h>

thanks, that fixed it, i was including an unnecessary library and the functions were conflicting.
now it all works perfectly