Which text does the four sights story come from?
Possibly a later development based on AN 3.39. In that sutta, the Buddha didn't explicitly mention He saw those signs but the ideas were there:


  ...Amid such splendor and a delicate life, it occurred to me: ‘An uninstructed worldling, though himself subject to old age, not exempt from old age, feels repelled, humiliated, and disgusted when he sees another who is old, overlooking his own situation. Now I too am subject to old age and am not exempt from old age. Such being the case, if I were to feel repelled, humiliated, and disgusted when seeing another who is old, that would not be proper for me.’ When I reflected thus, my intoxication with youth was completely abandoned...