Hi,
Most likely, some build parameters (e.g. optimizations, libraries, etc.) are different. Since both VisualGDB and STM32CubeIDE use the same compiler (gcc), you can get them to produce nearly identical output (the only difference will be the order of symbols in the image), however it will require comparing build command lines side-by-side. We have a detailed tutorial showing how to do it for another compiler here.
Another option would be to use the Embedded Memory Explorer to quickly compare the footprints of 2 builds to see if there is any obvious difference (e.g. some symbols only present in one file, or every symbol being proportionally larger, implying different optimization).