2. Question: Why is one allowed to enter a bathroom or bathhouse without a halachic question fully answered but cannot start Shemone esray if he did not finalize an answer to the halachic question he was thinking about?
A. In both cases one cannot think about the question, in the bathroom or bathhouse because it is forbidden to think Torah in dirty places and by shemone esray because it will ruin his concentration.
Answer: The Shach says in Yoreh Deah 246:28 that the more one tries not to concentrate or to remove the question from him mind while davening then the more distracted he will be from davening. Meaning trying to distract oneself from the question so that you can Daven with more concentration will cause you to have less concentration on your davening and more concentration on distracting yourself so it is counterproductive. But when walking into a dirty place you just have to distract yourself and everything is fine. See Dirshu Mishna Berura 85:2:8:4.