Solution
(a) Since, both the blocks will move with same acceleration (say a) in horizontal direction.

Let us take both the blocks as a system. Net external force on the system is 20 N in horizontal direction.
Using 20 = (4 + 2)a = 6a
or a = 
(b) The free body diagram of both the blocks are as shown in figure.

Using∑ Fx = max
For 4 kg block :

For 2kg block :
Here, N is the normal reaction between the two blocks.
Note: In free body diagram of the blocks we have not shown the forces acting on the blocks in vertical direction, because normal reaction between the blocks and acceleration of the system can be obtained without using∑ Fy = 0