The last few seconds of time series are shown as a separate time series, despite using sum()

Hi everyone,
As you can see in the screenshot, I have a graph for memory usage per namespace, for a Kubernetes cluster. It mostly works correctly, the problem is that the last few seconds always show as separate time series with different colors. And each time series is shown twice in the legend below the graph. If I click one of the entries in the legend, the other one with the same name is selected as well. For example, if I click the green “default”, the orange “default” is selected as well and the graph shows only those 2.
How can I remove these duplicate time series from the last few seconds?
I have Grafana version 9.3.8.
Thank you