Yes. I am not aware of any hard and fast rule, but as a general rule of thumb, it is usually discouraged to edit your question in a way that invalidates existing answers. See https://meta.stackexchange.com/a/286804/160917 and https://meta.stackexchange.com/a/136371/160917.
It is acceptable to edit your question based on comments. But it is usually not a good idea to edit your question to change it based on answers.
Why? Because that wastes the time of people who answered the question. On Stack Exchange sites, some people may potentially consider this impolite.
Our mission is to build an archive of knowledge, in the form of high-quality questions and answers. It is not designed for interactive help or back-and-forth interaction. Leaving a page in a confused state, where the question asks one thing and some answers respond to an earlier version of the question, is not helping that mission. Wasting the time of answerers endangers that mission, because it risks driving away answerers. (See optimize for pearls, not sand.) Chameleon questions, that change after each answer, can be frustrating, and are not desirable or something that is healthy for the site.
If you discover, after reading an answer, that you asked the wrong question, usually the best response is:
Leave the existing question unchanged, and accept that the question you asked isn't quite the one you wanted answered;
Ask a new question that more accurately captures what you want answered;
Treat this as a learning experience. It is an opportunity to learn a lesson about the importance of being precise and careful in the formulation of your question, right from the start, and to practice more care in formulating questions in the future so that this doesn't happen again.
For onlookers: Beyond the general question (which is applicable more broadly), there is some context/backstory that might or might not help understand this poster's experience. See, e.g., Is it considered to be bad form to update a question to address objections raised in answers?, Is this definition of a decider technically correct?,
Is it considered to be bad form to update a question to address objections raised in answers?, Must a partial halt decider be a pure function of its inputs?, Appropriate measures for repeatedly posting the same content across the network.