They can be from different kits, just make sure the specs are the same, ie; Clock speeds, CL latency, memory size. Even if a few of these didn't match it could still work, but it could either hinder performance or cause random blue screens every now and again. Systems these days are pretty flexible but still require some tinkering to make work without issue.
Actually, memory compatibility issues are just as fickle as they've ever been. Not as bad perhaps in the VERY long ago when it was absolutely mandatory that all installed memory be exactly, EXACTLY, the same, including almost always, having come off the same assembly line and production run using all exactly the same components for the module build, because motherboards back then didn't have the same level of auto configuration capabilities as modern hardware, but the fact that there is SO MUCH different hardware these days contributes greatly to the problem as does the fact that quite often it is the specifications that you DO NOT see advertised, such as secondary and tertiary timings, ICs that are favorable to a given platform, better or worse CMOS hardware tables that can affect the degree to which a motherboard might be capable of finding equitable settings for different DIMMs and even some CPU related specifics can all contribute to things working or not.
The is only ONE way that is guaranteed to work and that is by buying a kit with ALL of the memory you want included AND making sure it is either validated as compatible for that motherboard by either the motherboard manufacturer or the memory manufacturer, with emphasis towards the memory manufacturer since they tend to do more extensive testing of their own products than the board manufacturers do. Even then, we've seen a fair number of cases where a memory kit shows validated for a given board for it's XMP or A-XMP profile, and across the board still has problems.