Why are some contrails longer than others?
It is a mixture of factors. All else being the same:


a contrail at a higher altitude will last longer (the lower temperature slows the sublimation of the ice cristals)
a contrail formed in air with higher humidity will be bigger and last longer (more water is being turned into ice)


If there is not enough (relative) humidity, the contrail will not form at all. See for example this image:

Image from NASA

The contrails start forming on the east, near the clouds where you have a higher humidity, and do not form on the west, where no cloud is present and you have higher temperature/lower humidity.


  I've often noticed that planes flying on more or less the same track, headed in the same direction leaves different contrails. 


What you observe might be airplanes flying at different altitudes and thus encountering different humidity/temperature combinations, giving birth to contrails with different histories.