It's like a search for "pregnancy symptoms" on Google—sure it doesn't specifically tell Google that you or someone close to you is pregnant, but you'll start seeing ads for baby stuff anyway because odds are you are.
If you’re a male, age 45, with kids, and you suddenly are looking for apartments and your porn habits change, you’re going to get more gambling ads. Companies use third party data to correlate outside activity to Google.
The government has used it to deter radicalization and to redirect people with opioid issues. You can compare online behaviors with say health insurance claims and lifestyle factors and score likelihood of events. Once that correlation is done, you can target ads to influence behavior.
Hacker News is the same way. HN does not send your HN handle information to any third party. That said, your posts and comments include certain metadata, including your HN handle and a link to account metadata as per the privacy policy. This data is public and may be accessed by third parties.
2. Why is sharing metadata with unknown arbitrary 3rd parties OK? Not all metadata is or should be public.
Even in the silly HN example, you can analyze referrer data and build profiles of people, without any cooperation on HNs part.