The way in which the highlighting works is that Visual Studio uses the language parser to analyze your code, and then selects the brace that matches the opening one, in such a way that they both enclose the same "logical block". This means that if you select the { at the beginning of an "if", it will highlight the } that closes the "if" block in accordance with the compiler. This may not necessarily be the first } after the selected one, because the "if" block might have other nested blocks that contain their own opening and closing braces.
Note that Visual Studio can get very confused when there are any syntax errors within the code. Then the parser will not be able to analyze it properly and therefore will not be able to find proper matches for the braces. In the particular example that you showed, there are syntax errors because the braces are unmatched (superfluous brace before the second anim.SetBool). Therefore, it is not unexpected for Visual Studio to fail to match them in the way that you think they should be matched.