Kind of tricky for me to give a precise explanation, but it generally has to do with frame of reference and whether it's referring to a measure/distance or to a place.
'I spotted you from a distance.' Here it is used as an imprecise measure. It just means from an arbitrary distance, it could be I spotted you (identified you) from 10 feet or 100 feet.
'From a distance, you could be mistaken for Joe.' Same here, 'a distance' being an arbitrary/imprecise distance or measure.
'He emerged from the distance.' The distance here is a place rather than a measure.
"The small house was visible in the distance." Same here, 'the distance' is an imprecise place or location. Could also be inferred to be an arbitrary distance or measure so this isn't 100%, but I think it's fairly instructive.