ESP8266 erase program from memory

Hi,
I have a problem with overwriting a sketch to ESP8266. After numerous of times of trying to overwrite a program, it just goes all over again. I have also tried to erase the flash memory (Erase flash memory like Magic 🪄🎩 | ESP8266 | ESP32 - YouTube) but it didnt help. Can somebody help me resolve the issue ? Thank you sooo much.

board used: https://techfun.sk/produkt/arduino-mega-wifi/?currency=EUR&gclid=Cj0KCQjw3eeXBhD7ARIsAHjssr-JHCQQ0kwHxIUnj-Oj5mDyGFgX_Rh3IljkUlM9rnMTxhi_t4LtIfoaAg-AEALw_wcB

Technically speaking that is a board with 2 (Processors + Flash + RAM)
On which of the 2 are you trying to overwrite the program of and how are you trying to do that ?

I am trying to upload a sketch to ESP8266, but as I sad, I cant. I have tried all the methods I have mentioned - overwrite it with the other sketch and to erase the flash memory with the steps mentioned in the video.

You do realize you don't need to "erase memory" to upload a new sketch, right?

You failed to give any details about what happens when you attempt to upload a sketch. There is a normal, routine upload procedure using the IDE? What happened?

And you have set the dipswitches correctly ?
You have installed the ESP8266 core ?
What response does the IDE give when you try and upload any sketch, say 'blink' although since that board does not have direct access to any of the ESP's GPIO pins which is a tad unpractical. so maybe you should upload something like

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println("Hi");
  delay(1000);
}

and see if you can receive that on the Serial monitor.
Dipswitches should be the same as for upload except for the GPIO0 not being connected to GND

I am, but I am desperate and trying anything. Inhave sad what is happening. It always runs the same sketch that I uploaded earlier, but I am not able to upload anything else instead. It just ignores the new sketch and runs the same code all over again.

Dipswitches that are being used are 5,6,7, which are supposted to upload a sketch to ESP8226.

.
I have uploaded a few sketches succesfully before so the ESP8226 core is installed correctly. Am not having trouble to upload any sketch, I am dealing with the fact, that I can not overwrite a script that I uploaded earlier. I can use any other sketch and try to uload and run it but ESP8226 just ignores it and runs the old one even though I have deleted it from my computer. So i suppose it “remembers it” somehow. That is the issue.

That is not really possible. And you are not providing enough details here.
So upload the sketch i posted with switches 5, 6 & 7 'on'

Which core are you using ? and what have you selected as a board and flash size ? (and why )
So what does the IDE tell you after this upload ?
(please just copy and paste the message here (within code tags)

then turn switch 7 'off' , reset the board and open the serial monitor with the baudrate set for the 115200 that is used in the sketch.
What do you see ?

That none of the ESP's gpio pins are exposed is unpractical, but you could actually get access to GPIO 0 fairly easily. Switch 7 has 1 side connected to GND and the other side is connected to GPIO 0, and you can solder onto that fairly easily. Then if you connect a LED + Resistor to that and 3.3v (so that it is active 'HIGH') you actually will have a usable led. Of course there may even be a builtin LED on it (on GPIO 1 or 2), but i don't have the manual for your board.

Please enable verbose output for upload in the IDE settings, then copy and paste the entire upload listing here in a new message.

The code I am trying to upload to ESP8266

Output: (as you can see it runs something different that I have uploaded earlier.

The middle picture is completely unreadable, but if we haven't i'll ask you again 'Do not post screenshots !'
But copy the data in the window and paste 'in between code tags </>' so we can read what you have posted.
The output from the compiler will tell us what you have selected, but this i can not read.
Most likely there is something wrong in the code that causes the esp to reset, so why don't you try to upload a simple sample code first.

I have tried to upload a multiple versions of code, none of them worked. That is the issue

We can not help you if you do not provide the information.

None of what worked? The uploads, or the code versions? Upload to what, the Arduino, or the forum?