It prints this code because you have it open in another editor tab. Wish people who don't know at all how it works stopped acting all outraged when they're laughably wrong.
Can you link to more info about this? If this is accurate, many people aren't aware.
Code Snippets Data
Depending on your preferred telemetry settings, GitHub Copilot may also collect and retain the following, collectively referred to as “code snippets”: source code that you are editing, related files and other files open in the same IDE or editor, URLs of repositories and files paths.