The same way that Delta has decimated Flu Type B/Yamagata to the point that some are whispering that Flu Type B/Yamagata has gone extinct. (The Flu is still around, but Type B/Yamagata was very, very common before COVID19 hit. It hasn't been seen for almost 1.5 years now)
Its not like "Delta-variant" gives you immunity to Flu Type B/Yamagata. But people around the world are masking up and locking down (well, in 2020 anyway). People's behaviors change when a large-scale pandemic like this occurs, and the weaker viruses die out.
Even ignoring that, COVID19 forces an immune response. Yes, this immune response includes memory-cells (which remember COVID19's signature), but it _ALSO_ increases other immune cells (Neutrophil, killer-T cells, among others) which will hunt down any virus more effectively. This effect is temporary, but still a big enough effect to see the body fight off other diseases a bit better after getting sick from anything.
So even though COVID19 / Delta doesn't give you any immunity (ie: memory cells / antibodies) to Flu B/Yamagata, you see Delta outcompeting it and driving Flu B/Yamagata to extinction.
--------
Delta transfers memory-cell responses + antibody responses (two attributes of "memory immunity") against COVID19, and Alpha, and other variants. Sure the disease is evolving, but its not like these antibodies are totally useless against the virus within the same line.
COVID19 simply doesn't evolve as quickly as the flu does.
--------
This effect, in reverse, was seen in 2020 where recipients of the standard Flu shot had something like a 5% lower chance of getting COVID19. The temporary "immune response" that your body built up for the Flu vaccine had a minor (but measurable) effect on COVID19.
Getting sick with _ANYTHING_ makes it harder for other viruses to attack you. Your body just goes into overdrive making various white blood cells.