At least in prior Google Analytics versions, a third party cookie was used, giving the possibility to link you to every site that implements Google Analytics. But Google explicitly states not to do this, so you are correct in calling me out here.
GA4 still uses the doubleclick cookie. It also encourages the use of Google Signals and runs measurement requests off of the main google.com domain to help it track users based upon their Google login.
If site A and site B both uses GA, then GA track them across both internally for their stats (and it helps google in figuring out the same user has interest A and interest B).
Matomo promises to not do the same link across properties on their cloud hosted version.