You are correct, picking out your own parts is often better. In terms of compatibility, you can do it by using sites such as pcpartpicker.com, when you select components here, the site will tell you if there any compatibility issues.
In terms of motherboard and CPU compatibility, look at the socket type on the motherboard and the CPU, if they are the same then they are compatible