Why file links appear in the folder sidebar and how can I prevent this from happening?
You might accidentally be pressing the shortcut commandT which means “Add to Sidebar” in the Finder but is used for many different things in many other applications. So if you think another application is frontmost where actually the Finder is you'd accidentally add the currently selected file to the sidebar. Happened to me a few times.