I've analyzed raw tracking data from gpx files from various devices on various hikes over the years. When you look at the raw data you quickly realize why there is so much difference in reported mileage and elevation gain between devices and even different apps on the same device/phone. The data is extremely noisy and needs to be filtered to separate the signal from the noise. Every device & app has slightly different filtering algorithms. The "true" number is typically impossible to know from GPS data alone. Routing apps (e.g. caltopo) can also be inexact due to accuracy issues in the underlying data they use to determine the route and elevation along the route.

Just click through the recordings of any popular trail on Alltrails and you'll see track after track with the exact same shape (not including alternate routes) but noticeably different mileages and elevations.