A lot of the time this happens because the illness that the medication is intended to treat is also prevalent in the people who are being treated with said medicine. For example, most antidepressants come with a increased risk in suicide, but that's primarily (although not entirely in most cases) because a depressed person is more likely to be taking a depression medicine and also more likely to commit suicide.
[more you know star GIF I'm to lazy to google, but apparently not too lazy to type all this out, which is arguably more work}
In case of the increased suicide risk, there is also the fact the first effect of the medication felt is increase of energy, so the person might be more likely to actually act on their suicidal thoughts.