Question: I understand that one of them is actually the other. At first we are led to believe that Vincent is Ergo. But toward the end of the series, we discover something but I am not sure what it means: Ergo created Vincent to run away from himself. Also, in the beginning, when Vincent turns into Ergo, he loses control and doesn't remember any of it. Later on he starts to control Ergo, but at the same time he can talk with him.

So, basically, I don't understand which 'came first':
Is Vincent Law Ergo Proxy? Or is it the other way around? Or are they actually two different 'selves' that 'reside in the same body'?

Answer: 
From what I understand, Proxy 1 and Ergo Proxy are two separate entities. A miss conception, thanks to the English translation, is proxy 1 created Romdeau; this is not the case as Romdeau is described a flawed Dome in the same way as its creator, Ergo Proxy, is a clone on Proxy 1 and hence a flawed proxy (also shown by the fact he can survive UV rays). 

This is further backed up by the relationship between Ergo and Monad. Monad we are told loved Ergo proxy due to their opposing natures of life and death, thus she comes to Vincent AKA Ergos aid at the end of the series rather than to help forefill Proxy 1's ambitions for Ergo to destroy humanities chance for a future on earth.

Vincent is therefore the human name of the being Ergo proxy while he has amnesia due to the removal of his own memories to prevent him from becoming the literal grim reaper on earth. Ergo Proxy was created a long time prior to the series by Proxy 1 as a means of revenge on humanity.

Of coarse I could be completely wrong but it doesn't really matter as the main focus of the anime isn't the plot but the moral and theological questions which arise from the setting and premise of the series. In short its a fantastic anime whether the ending is ambiguous or not :)
Vincent Law is Ergo Proxy, who is Proxy 1. Proxy one divided himself into two. That which is divided must become one. So Proxy 1 splits into 2, and one half leaves the dome, the other half remains. The half that leaves gets rid of their memory... who are they now? They are no longer the true Proxy Project creation. They are now gaining self-awareness and forging a new identity.

It is perhaps because they rejected their imperfect origin that they decided to dump their memory, and become Vincent Law. Victory over Law. He has claimed victory over the rules. He is no longer just a proxy. The amnesia effect allows us to follow him on his journey against the strongest enemy he'll ever face... himself. A journey we all must take if we strike out against what we were planned to be and instead seek out our own destiny.

So Proxy 1 is Ergo Proxy... He is both one and the same, and he must embrace every aspect of himself if he is to truly choose his own future. It's not an easy thing to do, but he has Re-l, or reality. He also has pino, and "in vino, veritas", or "in wine there is truth".

So moving forward with reality and truth, the lab project known as Proxy One will eventually embrace that he is Ergo Proxy, and yet overcome his origins and finally reach happiness by redefining himself as Vincent Law, victorious over the laws his very cells were programmed to follow. He felt the pulse of the awakening, and instead of dying, he awoke. He is the agent of death... or was... not anymore... He is Vincent Law, and Vince is in full control as he sails off with truth and reality, and a new autorave who perhaps represents the discipline he has finally achieved.