It’s basically because obesity (for example) has an association with BOTH drinking diet soft drinks (because obese people use them to try and lose weight) and having a stroke (because obesity causes strokes). So when you do a study like this, obesity is what’s known as a ‘confounding’ variable, because it can cause people both to have strokes and drink more diet soft drinks.

This means that any results that you see when you look at an increase in strokes in people who drink diet soft drinks can potentially be explained by the fact that these people are just more obese in general and so more likely to have strokes than people who don’t drink diet drinks.

Here’s a much longer and better explanation