Am I allowed to walk past a shul without going inside? Would doing so be disrespectful? Should I go another way if possible?
The Talmud (Berachot 8b) discusses this question by saying that one may not walk past a synagogue at the time the community is praying without going in. The reason seems to be, as you suggest, that it looks disrespectful to pass by when everyone else is praying. Another reason may be to avoid causing a bad reflection on oneself by appearing to disregard the community and prayers.
However, the Talmud makes several qualifications. For one, we see that the problem would only be if one passes by at the time of the prayers; but at other times, there should be no problem. Also, the teaching notes that this is only if there is only one door; but if there is another entrance, there’s no problem since onlookers will assume he will enter the other door. In addition, even if there’s only one entrance, if there is another shul in town, there’s also no problem since it’s assumed he’ll go to the other shul. Furthermore, the Talmud teaches, even if there’s only one entrance and only one shul, it’s still okay if he’s carrying a heavy load, or running or wearing tefillin. These extenuating circumstances also preclude disrespect or suspicion: one carrying a heavy load is obviously preoccupied; one who is running must have some urgent need; and one who is visibly G-d-fearing and observant is obviously not disinterested in things of that nature and must also have some justifiable reason for not entering the shul.
Since nowadays most communities have several shuls, and many shuls have several minyans, it seems that in most scenarios where a person walks past a shul when prayers are taking place it will be assumed that either he has already prayed, or will pray. That being said, if it’s not too much of an inconvenience, it might be better to take an alternate route if possible.