If a key prints a different symbol from its keycap, first check the active input source. A regional layout mismatch can change punctuation while the keyboard hardware works normally.
Compare a few known keys
Open a blank document and test letters, numbers and the symbol that seems wrong. Check the Input menu in the menu bar, then switch to the layout intended for your keyboard if necessary.
Do not test by entering a password repeatedly. A disposable text document makes the actual characters visible and avoids accidental account lockouts.
Use Keyboard Viewer as evidence
Show Keyboard Viewer and press Option or Shift. If the viewer predicts the symbol you are seeing, macOS is interpreting the key according to that layout.
If the viewer and output disagree only in one application, inspect that application’s input or keymap settings. Remote sessions and browser-based editors can add another interpretation layer.
Separate symbols from modifiers
An external keyboard with Command and Option in unfamiliar positions may need modifier remapping. That does not replace selecting the correct language layout; the two settings solve different problems.
If one physical key is intermittent in every app and with the correct layout, investigate the keyboard or connection. TapNoise’s sound feedback can confirm an observed key event, but it does not diagnose a damaged mechanism or guarantee that an app entered the intended character.
Sources: Apple’s Input Sources settings, Keyboard Viewer.
TapNoise