Lara knew like William that danger wasn't over. He was inside the corridor leading to the Lost City, entrapped there, unable to get out through any door.
William tried to open all the doors here, not knowing which one led to Lara's place. But he was willing to take the risk. Appearing out of nowhere, even in the middle of hostile lands, was something that'd take his enemies by surprise.
He planned that during the commotion of his sudden appearance, he'd slip through and make a run for his life towards Lara's portal area. However, he was depressed to find out that he was unable to open a single door.
He guessed that these doors must be opened by something like a key or something. He managed to slip here as he already saw how the merchants did it before. As he got entrapped, he got two options, either to go into the Lost City and hide himself there, or to ask help from Lara.