It looks like Strava's GPX importer completly ignores "trkseg" XML tag. In attached file there are two segments.
GPX file contains one track (trk XML tag). This track can have one or more segments (trkseg XML tag). Segment have points (trkpt XML tag). Distance should be counted as distance between all points inside one (and every) segment but not between segments.
Example: Let's have one track with two segments.
First segment: point A, point B, point C Second segment: point D, point E
Distance should be counted as: track_distance = distance(A, B) + distance(B, C) + distance(D, E)
You count it as: track_distance = distance(A, B) + distance(B, C) + distance(C, D) + distance(D, E) (which is wrong, distance between C and D must not be in total distance)
Distance between last segment point and first point of next segment must not be counted in whole distance.
According to GPX specification:
https://www.topografix.com/GPX/1/1/#type_trksegType A Track Segment holds a list of Track Points which are logically connected in order. To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new Track Segment for each continuous span of track data.
Last Track Point of Segment is not logically connected to next Track Segment. You are violating specification and counting completely wrong summary distance.