In general, parts that don’t fit won’t work, and parts that do fit might work. Usually there are subtle differences that a trained eye can spot. The label helps too of course.
For example, different classes of RAM sticks have the same dimensions but have the notch in different places so you don’t put them on a completely incompatible motherboard. However, within a class there might be different features that the motherboard wasn’t made for, such as the size of the memory, error correction, timing differences, etc., and while the RAM fits the computer may be dumbed down to match the worst unit or not recognize it at all.