I hesitate to answer this, as my views might be taken as just a rant, but I have a lot of experience - doctorate in mathematics and 40 years teaching mostly CS. Moreover, I've thought and written a lot about student learning.
My most basic question about exams is whether they tell us what we think they tell us and I think the answer is no. It depends on the exam, of course, but too many exam questions can be misleading and it is difficult to come up with good ones unless you revise and refine old ones, taking into account an analysis of old results. In one of the other questions cited by the OP, it took several suggestions by other academics to come up with a "fair" version of a question that didn't seem to be a minefield when first written, but turned out to be.
Other issues with exams (in fields like mine), is that too often an exam is simply too simple a vehicle to determine what a student has deeply learned at an operational level. Too many exams only test what a student has managed to remember from yesterday's cram session, as the high-risk nature of the process pushed them to actual destructive behavior. Can you make an exam for which cramming isn't going to be of any use. Yes, you can, but it is very difficult. It is even harder to convince them not to cram, forcing certain things into short term memory and perhaps obscuring more fundamental things.
Another issue, especially with the predecessor questions, is that when a student taking the exam (maths) gets an idea into their head it is very difficult to get it out, even when they realize that it is the wrong solution and isn't going anywhere. The first idea dominates the thought. Given enough time (not available in most exams) they might get it right, but the pressure itself is a mind-killer. This advantages some kinds of students, but not necessarily the most able or the ones with the best grasp. It is very complicated.
I have two suggestions, the first of which doesn't scale. That is oral exams in place of written ones. Now the questioner has a chance to interject if the student has made a wrong turn and can evaluate the depth of learning directly. The student has a chance to inquire about things unstated. But (personal experience here) the student also has a chance to explain why a first attempt is wrong, which may reveal a lot more about their learning than even a correct answer would.
But, that doesn't scale well. My major advisor also occasionally taught elementary courses (say Calculus) to moderately large groups and gave only oral exams (about 5 minutes each) and announced to the students at the end of the five minutes what their grade was. But even in a few minutes he could ascertain in broad terms how well the student knew the material just from their approach.
The other means, which scales better, is to rely less on exams altogether. Toward the end of my teaching I let exams count for no more than 30% of the grade. The rest being written work of various kinds, including group work. This lowered the pressure. Students could demonstrate what they had learned by demonstrating what they could do not what they could remember from yesterday. There was little need to cram and they were all promised a question that they would find very hard and that required interpretation, not memory.
Heavy reliance on exams scales well as exams are easier to grade than projects are to evaluate and comment on. But they also advantage a certain kind of person and disadvantage others. This is especially true, and I think unavoidable, if the exam is timed and important to the grade. People freeze. People prepare ineffectively. People have other commitments that get in the way of effective exam study.
However, there is one potentially positive aspect to an exam. Students do need to review what they have learned. That is an important aspect of changing the brain to solidify learning and turn it from simple rote learning into something that can be actively used. Lots of reinforcement of the learning. So, an exam that asks them to review what they have learned isn't a bad thing as long as it isn't so high pressure that it forces bad and unproductive behavior before or during the exam. In particular, essay questions, that ask for interpretations and consequences of things learned can be useful. I wouldn't want my courses to use only exams to help with this review and refinement, but it can be one aspect. I also sometimes used take-home exams with few rules forbidding things other than actual collaboration.
Most things, especially mathematics and CS, aren't actually produced in an exam-like atmosphere. I hope you will think about that.