How does Finder keep track of downloaded files' original URLs?
In the metadata associated to a file.  Use xattr from the command line to see and manipulate the metadata.  Using ‘get info’ in the GUI is not equivalent, but should allow you to see some metadata attributes, including the originating URL.