Finder -- "Open file with..." offers incorrect list of candidate apps When I right-click -> "Open with" -> ...

I see an option for atom 1.19.3 and 1.19.1.

However Spotlight locates only one Atom.app (which is found in Applications).

Opening with 1.19.1 succeeds. However it turns out my version of Atom is actually 1.19.3.

Opening with 1.19.3 however fails to do anything.

I notice from the same screenshot there is a similar duplication going on with VSCode.

What is the problem with my system?  And how to repair it?
You could try rebuilding the LaunchServices database using this terminal command:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user

This may fix the duplicate listings.