In brief: the Oedipus story existed before Sophocles' play. The events of the story are not all dramatised by the play.
Here's the story:
Laius is King of Thebes, and an oracle predicts, before the birth of his son, Oedipus, that Oedipus would one day be his father’s murderer. When born, Laius and Jocasta give Oedipus to a herdsman, ordering him to take him out beyond the city and kill him. Out of pity for the child, the herdsman gave the baby to another herdsman. This herdsman took Oedipus to Polybus, who adopted him.
Oedipus, now adult, is told that he is not the son of Polybus, and seeks help from an oracle, who tells him he is destined to kill his father and sleep with his mother. Oedipus flees from Corinth to Thebes in an attempt to escape the fate the oracle has predicted for him. As he is travelling, he gets involved in a dispute at a crossroads with a man in a chariot (Laius, his birth father) – and kills him.
As he approaches Thebes, Oedipus is approached by the Sphinx, who has been plaguing Thebes, and solves her riddle. In gratitude, the Thebans appoint Oedipus the king of Thebes, and reward him with the dead king’s wife, Jocasta (mum).
It is at this point that Sophocles' play begins: and all that happens in it is that Oedipus, through various witnesses, works out exactly what has happened to him and who he is. Jocasta, realising too, kills herself, and then Oedipus blinds himself. The events of the story have happened BEFORE the play begins.