It's not that the Doctor can't cross his own timeline; it's that he shouldn't. As stated by the President of Gallifrey in "The Three Doctors", it's a violation of the First Law of Time -- illegal (because very dangerous) but not impossible. The Valeyard was not the sort of person who'd let mere laws stop him doing what he wanted to do.
Additionally, the Valeyard wasn't technically the Doctor. He was a manifestation of the Doctor's evil from in between his twelfth and thirteenth incarnations, so essentially, he's just a part of the Doctor's mind; an aspect of him brought to life.