As said, GPS elevation is not very accurate.
On top of that, if your device doesn’t have a barometer, Strava will favour topographical data anyway, which isn’t terribly accurate if the elevation goes up and down a lot in a small area.
And then you have barometers. Strava will favour barometer data, but that is dependent on weather and air pressure. Really you need to calibrate it. On a Garmin that is typically done by telling it the known altitude at particular locations. I don’t bother and find it can be a fair bit off at times, but also vary during the ride and on a loop the end point (same as the start) can be higher or lower than when I started, often by 100ft!
p.s. You can tell Strava to ignore barometer data, and it will use topographical instead.
Main thing for me is consistency. So long as it’s roughly clocking the same elevation gain for me with the same device and ride, then it’s something I can compare. Comparing to other people is just plain inaccurate.
Even distance varies with device, especially if someone has a speed sensor on their bike, as it clocks actual distance rolled, not GPS.