This is not a duplicate of Autocomment when voting to close as duplicate as that simply indicates that the feature exists. This is a "how" question asking how this feature actually works, which that answer does not address.
I just voted this question as a dupe, with 3 other votes existing before mine. I then noticed that I automatically upvoted the top comment, despite it not starting with Possible duplicate of.
What's the exact criteria for finding the "duplicate comment" for automatic upvoting when I cast an extra dupe vote?
Also related: When a question is closed as dupe, all comment starting with Possible duplicate of deletes.