The heart of most PCs can generally be considered the motherboard. It essentially determines the requirements for all other connected components. This is the item you want to pick first for any build.
Other PC components are not guaranteed to be compatible with each other but can roughly be divided into parts that are more or less likely to compatible.
(Also note that laptop vs. desktop can bring it's own issues).
Assuming both PCs are desktops:
Least Compatible (Requires Research)
- CPU - CPUs have very specific requirements and are almost certainly not interchangeable between random motherboards.
- Memory - Even though often much more compatible than CPUs, memory tends to be specific enough that simply swapping some into another computer is unlikely to yield satisfactory results (if it is even physically possible) .
More Compatible (Still Not Guaranteed)
- Internal Cards (Graphics, Sound, Etc.) - Non-integrated cards such as those used for graphics, sound, etc. tend to be interchangeable assuming you have the correct type of card slot available on the motherboard. Be aware you still often need additional drivers to make sure these cards work correctly once transplanted.
- Hard Drive - Internal and external hard drives tend to be interchangeable assuming (again) you have the correct connections available. External drives that use USB tend to be the most compatible.
- Optical Drives - Internal and external CD/DVD/Blu-ray drives are similar to hard drives and the same criteria apply.
- Monitors - Another hardware item that comes down to (mostly) connectors.
Most Compatible
- External Keyboard and Mouse - Even when there are connection differences (i.e. PS/2 vs. USB), it's often extremely simple to use these items on other computers. Wireless keyboards and mice can present more of a problem but usually are fine assuming you have access to dongles and drivers.
???
- Power Supply - Generic power supplies can often be swapped but not always. The likelihood of incompatibility goes up if the computer is from a specific manufacturer (e.g Dell) since they may use custom connections to the motherboard and these items (PSU and motherboard) may need to be a set.
- Case - Similar to power supply units, generic cases tend to be interchangeable. That said, again, custom manufacturers (e.g Dell) may use particularly standoff patterns or front panel connections that aren't necessarily compatible with other components.
In your case, I would pick one PC that was more "powerful" (had the best motherboard, processor and memory) and then cannabalize compatible parts from the second computer. I would skip swapping the PSU and case unless I had a good reason. I would pick items from the More/Most compatible categories above to target in my swap.