Controling fan with temperature and relay (problem)

Hi, I need help with my project. I want to turn on the 12V fan using the temperature. I connected the fan to the relay and made the first code that switched on and off the fan. I wanted to add it to the DHT11 sensor and at a certain temperature the fan would be switched on. But the problem is that the fan is on even without going above the set temperature. I really need your help. Thanks for advice.

#include "DHT.h" // pripojíme knižnicu DHT
#define pinDHT 2 // nastavíme číslo pinu, kde je senzor
#define typDHT11 DHT11     // vypíšeme typ nášho DHT 
DHT mojeDHT(pinDHT, typDHT11); // inicializujeme senzor a jeho pin
int maxtemperature = 26;
#define relay 6

void setup() {
  Serial.begin(9600); 
  mojeDHT.begin(); // zapíname komunikáciu s teplomerom
  pinMode(relay, OUTPUT); 
  digitalWrite(relay, LOW); // turn the relay off to start
}

void loop() {
  
  // pomocou funkcií readTemperature a readHumidity načítame potrebné dáta
  float tep = mojeDHT.readTemperature(); //teplota
  float vlh = mojeDHT.readHumidity(); //vlhkosť
  // kontrola, jestli jsou načtené hodnoty čísla pomocí funkce isnan
  if (isnan(tep) || isnan(vlh)) {
    // při chybném čtení vypiš hlášku
    Serial.println("Chyba pri nacitani!");
  } else {

    Serial.print("Teplota: "); 
    Serial.print(tep);
    Serial.print("Celsia, ");
    Serial.print("vlhkost: "); 
    Serial.print(vlh);
    Serial.println("  %");
  }
  
  if (tep > maxtemperature) {
    digitalWrite(relay, HIGH); // turn the relay on to turn on the light
  }
 else {
  digitalWrite(relay, LOW);
 }
 delay(3000); // wait for 3 seconds 

}

What sort of relay are you using ?

Many relay boards sold for use with the Arduino are active LOW, ie writing LOW to them turns them on and vice versa

Thank you for reply. I am using this one link it says that it is LOW-LEVEL trigger. What does that mean?

It means to turn the relay ON, make the output pin LOW, OFF is HIGH.
How are to powering the relay board? You should not power it from the Arduino 5V pin but from a separate 5V supply, the Arduino supply can only power 1 relay safely, each relay coil needs 75 mA and more than 1 is to much load on the Arduino's regulator and may burn it out.

Try this edit (untested):

#include "DHT.h" // pripojíme knižnicu DHT
#define pinDHT 2 // nastavíme číslo pinu, kde je senzor
#define typDHT11 DHT11     // vypíšeme typ nášho DHT
DHT mojeDHT(pinDHT, typDHT11); // inicializujeme senzor a jeho pin
int maxtemperature = 26;
#define relay 6

void setup() {
  Serial.begin(9600);
  mojeDHT.begin(); // zapíname komunikáciu s teplomerom
  digitalWrite(relay, HIGH); // turn the relay off to start
  pinMode(relay, OUTPUT);
}
void loop() {
  // pomocou funkcií readTemperature a readHumidity načítame potrebné dáta
  float tep = mojeDHT.readTemperature(); //teplota
  float vlh = mojeDHT.readHumidity(); //vlhkosť
  // kontrola, jestli jsou načtené hodnoty čísla pomocí funkce isnan
  if (isnan(tep) || isnan(vlh)) {
    // při chybném čtení vypiš hlášku
    Serial.println("Chyba pri nacitani!");
  } else {

    Serial.print("Teplota: ");
    Serial.print(tep);
    Serial.print("Celsia, ");
    Serial.print("vlhkost: ");
    Serial.print(vlh);
    Serial.println("  %");
  }
 
  if (tep > maxtemperature) {
    digitalWrite(relay, LOW); // turn the relay on to turn on the light
  }
 else if(tep < maxtemperature -1){
          digitalWrite(relay, HIGH);
 }
 delay(3000); // wait for 3 seconds

}