This question is mostly about the broader Stack Exchange network, rather than Stack Overflow.
I have a recurring issue when I asking questions on Stack Exchange, across the whole network: very often, if I ask a question of the form "how do I do X?", I get comments or answers that boil down to "you shouldn't want to do X."
When this happens I feel I either have to get into the weeds of explaining why doing X would actually not be a terrible idea in my case, or else I have to try and make a case for why I should be allowed to ask the "how" question without having to justify the "why".
The first approach usually works eventually, but it takes a lot of time and often leads to further arguments of the "my workflow is better than your workflow" variety, while the second approach generally tends to fall on deaf ears and can also lead to a lot of unproductive discussion.
I'm not saying that I don't occasionally want to do things that are in fact a bad idea, or even that I don't sometimes fail to realise I have an XY problem. But I do think both of those things are relatively rare, and they don't change the fact that the "why do you want to do this?" line of questioning is often irrelevant to the question being asked, and very often leads to a lot of off-topic discussion.
I have two questions in relation to this phenomenon:
Is there something that I can do personally to avoid this kind of discussion on my questions, aside from not wanting to do things that other people wouldn't want to do? Are there tips on writing questions that will make them less likely to elicit this kind of response? Is there a good way to respond to this kind of comment that avoids the potential for off-topic discussion?
If others experience the same issue, is there something that can be done about it at the network level? If there was a FAQ or policy somewhere that would discourage this kind of response, then at least there would be somewhere to point people.
Note that there is a similar previous question, Why would you want to do that? or I can't see any reason to do that, but that question just asks for discussion of the issue - it doesn't ask the concrete questions about what to do about it.