As @TylerH said in the comments, this problem bothers many users in VS 2022, and many users have reported this problem to the VS developer community. I believe that the relevant team is currently optimizing this problem, and when enough users report this problem, the team will prioritize it.
In addition, after my test, if you change the warning level, such as changing the warning level to 2, the warning of level 3 for unused variables will disappear, but the wavy line under the unused variables will also disappear. If you accept this suggestion, you can refer to this link.