It's just metric, M8 = 8mm diameter (though there's potentially some variant in the thread, fine vs. course, but assuming something standard, like an M8 x 1.25), that's vs. an imperial spec that uses inches, ex: 5/16" (~7.9mm)
If you look at a screw/bolt, it has threads, right? There's a specification as to how many threads per X are on the fastener, more = fine, less = course (more or less), i.e., just because you match the diameter spec (M8 or 5/16") doesn't necessarily mean it will work.
My recommendation: take the part you're trying to match to a hardware store where they sell fasteners, and test for proper fitment.