Code search may show snippets, but it's clearly not separated from the rest of its code base, including the license. It may be your problem as a user of that tool if you pirate snippets out of the search results without honoring its license, but GitHub at least didn't distribute it without its license. A human judge would surely determine that a search result page showing a snippet and linking back to the project wouldn't constitute distributing the code without attribution. Copilot is a different matter. There is no way to know where the code came from, whether it's novel or verbatim copy of someone's copyrighted work. Microsoft _is_ distributing code snippets here sans its license.
Yes if you use a tool to violate copyright it’s copyright infringement. If you prod Midjourney into outputting near exact Starry Night that’s on you too.
So far no one has made a compelling case that Copilot itself is violating copyright.