Federation is a weird one with search engines. Each instance is indexed by search engines directly (if the admins allow it in robots.txt) and the web crawler will then index that Lemmy instance. It used to just be like this and thus a scraper would come across the same content in multiple instances and also find a bunch of back links to said other instances. The search engine would then classify the entirety of the fediverse as an seo hack and ignore it. This issue has since been resolved so now posts include a special HTML tag that tells the web crawler where the original content came from (I assume the instance which manages the content so the communities instance).
What this means is that each instance is individually competing in the search results. When I crawler discovers lemmy.world content through accessing the lemmy.zip instance it knows the content came from lemmy.world and thus rates the lemmy.zip content and by extension the post u where looking for as though it was a lemmy.world page. (I assume all the search providers don't say how their algorithms work).
Its a shame how this works as it means that each instance has to outperform the competition individually instead of being able to work as a collective. Ideally the fediverse would have a single domain that search engines can be told is the content origin and thus the fediverse would be able to compete as a collective.