The behaviour described is unusual, but the symptoms alone do not establish whether the cause is a hardware problem, a macOS issue, or an interaction between the two.
The fact that 2, W, S and X intermittently fail individually, while appearing to work with Shift or Fn/Globe, is useful diagnostic information.
The fact that the problem sometimes follows an accidental Caps Lock press is also interesting, but it does not establish that Caps Lock is causing the problem.
Similarly, the fact that Keyboard Viewer works normally does not determine whether there is a problem with the physical keyboard.
Since the recommended Apple troubleshooting has already been completed and macOS Tahoe has been reinstalled without resolving the issue, it may be useful to see whether the problem can also be reproduced outside the normal macOS environment.
On an Apple-silicon Mac, Apple provides macOS Recovery and Apple Diagnostics for this purpose.
Recovery can be started by holding the power button until the startup options appear and then selecting Options. (Apple Support)
Apple Diagnostics can be started from the same startup options by holding Command-D. In macOS Tahoe 26 and later, Apple Diagnostics includes a specific keyboard diagnostic. (Apple Support)
If the affected physical keys behave differently in Recovery, at the login screen, or during Apple Diagnostics, that would provide useful additional information when discussing the problem with Apple.
If they behave normally outside the regular macOS environment, that could make further investigation of macOS or input handling more relevant.
At this stage, I would avoid concluding that the problem is definitely a keyboard-matrix fault, a Caps Lock problem, or a macOS Tahoe bug. The available evidence does not establish any of those explanations.
Apple's general guidance for a Mac that does not respond correctly to key presses is also relevant: If your Mac doesn’t respond to key presses.
For the diagnostic tests, see Use Apple Diagnostics to test your Mac and How to start up from macOS Recovery. (Apple Support)