I am confused at first you said cookies generated by a specific domain will not be shared with another site, but then you said they can track you and see where you went. They can also see my history.
I'll see if I can explain this without getting too far into the weeds
So let's say you've got Website A (where is a specific, unique domain), it can read-write cookies that only Website A can access. Pretty clear, right?
Now this website, let's say they sell headphones, are all sorts of assets loaded from the sites servers: markup/HTML, scripts, images - the servers provide storage for the sites products, user accounts, etc. Again, simple.
So one of the things the site loads is some ad code - the implementation particulars aren't important for this discussion - but think of it like it's own small website embedded into Website A. It can't read the cookies, but it can read some browser behavior, like the URL for a search page result from Site A. Also note, that while Site can't override the rules that prevent the ad from reading Site A cookies, Site +can+ share the same data it's storing in a cookie.
Additionally, the ad - again, which like a mini-site bundle with many of the same rules and functionality - an write it's own cookie for the "ad domain". Just like the ad can't read Site A cookies, Site A can't read the ad cookies.
Here's where the black magic occurs: when you go to Site B, also running the same ad engine, the ad can read the ad specific cookie, any Site A data that was allowed/given, ID you on the new site (Site B doesn't ID you, the ad does, again, like a mini version of the same website now running in Site B). So now, that ad in Site B, parses your search data from Site A, shows you on Site B the same headphones you were shopping on Site A. Site B and the ad could also, potentially share data as well - all within the limits of what Site B decides to allow and still enforcing core technology limitations like a cookie from a different domain can't be read.