A method I sometimes use, when it’s not completely random, is this. I make a selection of tracks based on key and BPM. The keys were found by automatic software and are not accurate, which is a good thing, so that everything is not too rigid. Let’s say samples in a range of 85-90 BPM and 4A on the Camelot wheel. This means they could go well with 4B 5A, etc. and other samples a bit slower by one or a few semitones down or a bit faster by one or sa few semitones up. Or one that's slower than half of 6 semitones down, etc.; it's worth noting that just because I've selected samples based on certain keys and BPMs doesn't mean I'll use them with those exact specifications; it's merely a way to create a basket of possibly compatible samples that I will, of course, listen to in order to choose them. The fact that the keys are not always precise is better. Sometimes the simple overlap of two loops creates magic. However, this fortuitous part isn't the most fun.
Now (something I copied because before hearing famous producers do it, I wouldn't dare), I try to use samples without putting them in time, shifting the accents, and using them in such a way that they sound like ghost notes and in off-grid positions to make everything more interesting, preserving as much as possible the nature of the sample as a "snippet" from another context while making it sound different—what was on-beat becomes off-beat, spinning the loop not on its original measure. Sometimes we use saples trying to make them sound as instruments. Here It Is the opposite. With this approach, it’s often possible to achieve a beat that sounds clunky, awkward, angular, in a way that wouldn’t be the same without the samples.