The short answer is: time travel. The Doctor crossed his own timestream. He can go "anywhere in time and space", as he's said on many occasions. If two (or more) of his incarnations go to the same time & place, there'll be two (or more) Doctors there. In fact, for most of "The Day of the Doctor", there were three (the War Doctor, the Tenth Doctor & the Eleventh Doctor) &, at one point, there were 13 (One to Eight, the War Doctor & Nine to Twelve).