Even though you may have done the exact same route as your friend, each GPS device will record its own unique set of data. This GPS varies according to recording interval (the time between GPS points), signal strength, GPS hardware, etc. Differences in GPS data can cause differences in the calculated elevation data. Strava also supports two different methods of calculating elevation data. Some devices (Garmin Edge 1000, Suunto Ambit2, Wahoo Elemnt, Bryton Rider 310) have built-in barometric altimeters which measure the slight changes in atmospheric pressure that correspond to your altitude. Devices that don't have a barometric altimeter use a known database of elevation data to calculate elevation changes along the route. You can read more about elevation here.