I wouldn’t worry about it. I see different values between Rocky 8 and Rocky 9 on two VM’s I have on VMware that have 4GB allocated. One has 3921 the other 3659.
You could have crashkernel/kdump enabled which can take 256MB of memory. Eg:
[root@rocky9 ~]# dmesg | grep -i crashkernel | grep -i reserv
[ 0.090448] Reserving 256MB of memory at 2816MB for crashkernel (System RAM: 4095MB)
so that can also explain the difference between one and the other, since Ubuntu doesn’t have that. In fact, if you take the Ubuntu value, and minus the Rocky value, you get approx 256MB so confirms what I wrote.