Towards an Understanding of Stepwise Inference in Transformers: A Synthetic Graph Navigation Model