Well, if you beat the third game, it shows that Proto Man was built first. It is believed that they were both built by Doctor Light and Doctor Wily and Proto Man had simply left or something so they made Mega Man.
"Doctor Wily, I say! Proto Man seems to have run off again!"
"FOOL! I told you we should not have given him free will of any kind!"
"Well, excuse ME if I was just doing what the doctor ordered!"
"You're not making sense!"
"No, YOU'RE not making sense!"
"We're building another one and this time it's going to be a slave! A SLAVE!"
And so they did. But this slave couldn't be persuaded into joining the evil ranks of Doctor Wily and his endless army of robots as he made off with all the robots working in the Doctors' lab!
You have to wander why Doctor Light joined forces with such a sneaky character as Doctor Wily.
"So... Your resume says that you've been known to constantly backstab everyone you have ever worked with! But are you a good listener?"
"Of course!"
"YOU'RE HIRED! Let's build a bunch of powerful, threatening robots together, new bestest buddy!"