Did you ever see your Google Analytics code, for your website, on someone else's site? It happens for some reason here and there. But if it does, there is no reason to worry that it will impact your SEO or Google search rankings.
It might impact your analytics data but it won't make you rank higher or lower.
John Mueller of Google was asked about this by Shashi R who wrote:
Someone added my website analytics code by mistake in there website and they going to address it after long time is it impact my website SEO performance like crawling, indexing, keyword ranking.
John Mueller replied:
It wouldn't affect your site's SEO.
This Q&A was on Bluesky and I guess it makes sense why someone might worry about this. But as Google said numerous times, it does not use Google Analytics data for rankings, if you believe them.
Forum discussion at Bluesky.