I don't understand what $_interval does

I know there are tons of resources about this but something doesn’t add up to me.

According to what I have understood $_interval is a variable that takes the interval from this dropdown menu:
image

So that the panel displays the correct information according to that interval. If that’s true then I’m doing something else wrong.
I have a simple database with the following values:
image
These values store energy.

See response for the rest of the problem (I can’t attach more than 2 images)

I want to display it on a gauge that shows the Energy for the specified interval:

In total according to influxdb there are 32+32=64Wh of energy. However, for some reason Grafana displays Wh.

Now, if I group by 3h instead of interval (which is in thery the same because that was the interval that was configured as you can see on the previous picture):


Everything works fine.