They don't just serve ads - they sell sentiment data. Have you ever posted somewhere like Mumsnet? If you did, a data agency picked up how you felt about whatever you were talking about and they fed it back to companies who like to sell things to you.
They built a profile of you, who you interacted with and how, and they learned quite quickly how best to make you buy things. It didn't need to be an ad served there and then in the feed (though the algorithm does use this) but make no mistake, you became the product.