I know one advantage of using Contersink bolt is that the surface can be flat as the screw head gets embedded. If I want to join two parts together using bolts. What are the pros and cons of using Countersink Bolt vs. Socket Head Cap Screws? Which is more secure in combing the parts?
The hex socket in a countersink will always be smaller than the socket in a hex socket capscrew. It's not so great at the smaller end - M5 countersink uses a 4mm hex, capscrews use a 5mm hex vs. 12mm and 17mm for M20.
Some time in 20 years, someone might want to remove that screw, which has rusted in through never being touched, you can bet they'd be swearing at their bendy noodle Allan key if you've specified a countersink. In my time as a fitter I used to curse countersinks, they always seemed to be harder to remove and always fitted sort of poorly because they didn't have the clearance around the bolt than a cap head, allowing the assembly to move a little to line things up.
Cap head every time, if you need it below the surface, counterbore it in. Only countersink if the material is thinner than the height of the bolt head and you can't counterbore.
There's no mechanical reason why one is better than the other, countersinks are just more awkward to work with.
Counter sunk screws have an additional advantage that I haven't seen anyone mention. They are self centering when used in a tapped hole. You can give the screw hole a generous clearance, and when the screw is tightened down, the parts will still be forced into alignment (in the plane perpendicular to the screw). I find that this is usually an advantage, but it can also be a disadvantage. A cap head screw with an oversized hole can accommodate some misalignment without warping the parts being attached.
Also adding to something others have mentioned. A caps screw above the surface is the simplest mechanically. But if you need it to be flush, drilling a countersink is usually much easier than drilling a counter-bore.
Cap screws can be installed in slots and flat heads can't (that I know of).
Here's how I would choose: If centering or flush installation aren't required, I'd go with a cap screw by default. If I need either one of those, I switch to flat heads. For something where brute strength is required (like an automotive frame), I would prefer a regular bolt, not countersunk. Not so much because of the bolt strength, but because of the material removed for the countersink.
Both do the job well, but the countersink bolt requires extra effort as you require a counter sink in the part. The socket head cap screws don't need any extra cutting. In aeroplanes or rockets or even in racing cars, you don't want pieces jutting out of the surface causing extra drag and so you'd use countersinks.
Maybe socket head cap screws won't self-loosen as easily as countersink bolts, but if you've done your calculations correctly, you'll have nothing to worry about and either bolt will do.