Scope of the problem and appropriateness of measures It is not clear to me whether there is a significant number of flawed answers with (undeserved) high scores. I don't doubt that there are instances of this pattern, but I would like to see hard data that confirms that this is indeed an issue that warrants new 'upvote rules' or even a radical change to the workings of the site (it should be noted that 'we' can't unilaterally change the way this site works in a way to require a knowledge test before one can answer, comment or vote and that the powers would quite probably not look favourably upon such a proposal since Stack Exchange is already seen by some as an elitist place). I have probably backed myself into a corner demanding hard data on vote patterns (which are not openly available), but I feel that it is important to realise that a stark change in the site's dynamic needs a good reason: You don't want to shoot sparrows with cannonballs as they say in German.
What level of flaws are we talking about? It is probably true that some highly-voted answers have flaws by some standard or another. But keep in mind that one person's flaw might be another person's feature. Sometimes a balance needs to be struck between catering for every eventuality and keeping the code short and its explanation understandable. The concept of a flaw and the question whether or not a flaw is bad can therefore be quite subjective. At the same time the question whether or not an answer is suitable for the task described in the question is to a lesser degree subjective as well: Sometimes an answer gives the question a new framing or goes about resolving a XY problem. One may feel that the question has not properly been answered in that case, but one can also feel differently about that.
I doubt that there will be a lot of highly-voted answers that are outright factually incorrect. On the other hand I have no doubts that there are some answers that could be improved or for which more elegant alternatives exist.
Post score as a measure of quality It is also true that some (many?) people have had the experience that the answer score does not always reflect the post's quality or the time and effort spend on that post. One of my highest-voted answers is an answer to Force periods in "Ph.D. thesis" in biblatex that essentially just consisted of one redefinition of a string – I mean, the information is correct (in that the code will do what one would expect) and usable, but I would not rank this answer among the top ten of my answers on this site. On the other hand posts like my answer to How to make biblatex treat the prenote like an author list? only score 1 even though the question is much more intriguing, was more tricky and I spent a lot longer working out that idea.
Voting baselines can be different Different topics and kind of questions generate different levels of interest and so comparing scores across questions is probably not always a good idea: It would be more relevant to compare scores of answers to the same question. But even then the baselines can be seriously skewed by answers coming in much later than existing answers. The effect is amplified by the usual sorting order of highest ranking first, which means that people who are just looking for a working solution and are not shopping around for the 'most elegant' or 'conceptually nicest' answer vote for the first solution. Remember that for many people LaTeX is just a tool to get the real work done. The TeX code itself is almost never of interest, the result matters and so often one can get away with subpar or less elegant code.
If you want votes to truly and comparably reflect the quality of an answer (leaving aside subjective criteria of which there are still going to be a lot), you need a significant overhaul of the voting system. It would not only be about who is allowed to vote, it would also have to be about everyone voting on all posts to ensure a fair baseline. If that brings down the number of votes significantly below the current level (there are some highly voted an answers, but the median score of answers is around three), a simple up-down system might not give enough nuance any more, a more complicated voting/scoring system might be needed.
Guidance on voting behaviour In general there seems to be very little official guidance or rules about voting. This makes sense since an idividual's voting behaviour is not part of the public record and so there can be no enforcement of any sort of rules except for extremely abusive behaviour of the voting mechanism (serial voting, 'downvote targetting', ...) carried out by Stack Exchange staff. I personally think that it (only) makes sense to vote if one (firmly) believes that the post deserves that vote and that usually that belief should come from an understanding of the contents of the answer. But there are different levels of understanding an answer and probably only the highest levels of understanding allow for the judgement you seem to hope for. In particular then, only people who already know the answer should vote. People who by having read the answer have gained an understanding of the issue at hand and believe that the answer did well in enabling that would have to be barred from voting because their basis for voting would be the presentation of the answer and not the underlying facts themselves. I can't speak for anybody else, but a not insignificant portion of my votes were spent on answers that explained things that I did not know before well.
As for restricting answering (and commenting!) to people who have passed a knowledge test, that would go completely against the spirit of this network. The idea is that anyone here can ask and answer questions and share knowledge.
Level of the admission test I'm also not convinced that this is going to help much. Depending on your interpretation of 'flawed answer' you might have to set the bar pretty high to avoid small flaws slipping into answers (for highly voted answers serious flaws should be quickly identified if many people are allowed to vote and leave comments, but small corner cases may need very specialised knowledge that is not found in many). That may just turn the entire site into the seven gurus of TeX answer your questions – an interesting idea maybe, but certainly not in the spirit of Stack Exchange. Setting a low bar will mean that those who are able to find small flaws and never post answers with flaws themselves will be in the minority again. (Especially if one accepts that there are few answers with serious flaws that makes the restriction to people who pass a test not very attractive.)
A general test or tests for tags? Even though the TeX world may be small by some standards it is still so large that some people have specialised set of skills. You would probably be fine reading my
biblatex answers, but whether a
tex-core answer of mine is going to be good is a different question. Some people are great with TikZ, other with picture mode. A generalised knowledge test is not going to cut it if you want to cover more than the pure basics. Admitting users for different tags separately is going to be a huge ask. You need people setting the questions, you need a committee approving them, ...
I'll close this ramble by echoing marmot's advice (from their answer which I also otherwise agree with) on what you can and should do if you notice something is wrong with an answer: Leave a comment. Explain what is wrong. If you think you have a better solution, post an answer yourself (though you shouldn't expect it to rise very high if you are late to the party, even if it is superior).