Bear in mind that my answer is based on what I know about the Amazon affiliate program, and that dates back to a year or two, so things may have changed.
You are supposed to only put links to a certain category of products, normally those who are related to your area of expertise (e.g. if you are doing blog posts comparing microphones, then you can post links to microphones).
The easy answer is, of course, if the product you're advertising is haram, there is no question about it.
Now, if Amazon hasn't change, any product (not just the ones you linked to) that are purchased within 24h give you a commission. And, if Amazon hasn't change, there is no way for you to know which products were bought.
In Islam, when you have no clear indication in the literature, it often serves to judge things by example (i.e. comparing to a hypothetical similar situation).
Suppose you live next to a gigantic market, and you can give cards with a direction to a particular shop S in that market, and receive money if people follow your direction to shop S. Suppose they buy drugs in that market, is it your fault ? It depends. The deeds are judged with the intentions (إنما الأعمال بالنيات).
If you know that, to get to the shop S, they need to pass through 40 shops that sell drugs and that might tempt them, then you probably did something wrong.
If you know that 90% of the shops in the market are selling drugs, then you probably did something wrong.
If the market is truly enormous, contains less haram than halal things, and reorganizes itself, with each visitor, according to the cookies installed on the computer of the visitor, and therefore depend on what the visitor searched/bought before, then I do not see how you can be held accountable.
If, in the span of 24h, the person intentially bought drugs, then I see even less why you would be accountable.
However, if indeed Amazon changed and you are able to see what the people bought and where is your money coming from, then I don't know. But what I would do if I were you is measure: if 5% of the money comes from illicit things, donate that money. If 90% of it comes from illicit things... I would reevaluate my life choices and pick another occupation.
If in doubt, really try to meditate and ask yourself.
[The hadith in full: Al-Bukhari, Volume 1, Book 2, Number 49: Narrated An-Nu'man ibn Bashir: I heard Allah's Apostle saying, "Both legal and illegal things are evident but in between them there are doubtful (suspicious) things and most of the people have no knowledge about them. So whoever saves himself from these suspicious things saves his religion and his honor. And whoever indulges in these suspicious things is like a shepherd who grazes (his animals) near the Hima (private pasture) of someone else and at any moment he is liable to get in it. (O people!) Beware! Every king has a Hima and the Hima of Allah on the earth is His illegal (forbidden) things. Beware! There is a piece of flesh in the body if it becomes good (reformed) the whole body becomes good but if it gets spoilt the whole body gets spoilt and that is the heart."]