When both blocks move together, the friction between the two blocks is static friction which is $f\leµN$ and not necessarily $f=µN$.
So, you can't use $f=µN$, because it is only valid for a case when the pulling force is the maximum force which the two blocks move together, it means in that case, if you increase the pulling force by $\epsilon $, the blocks move separately.
Now, how to solve this problem:
1- Calculate the acceleration for the system of two blocks (6 kg). So, static friction will not be taken into account since it is an internal force for this system.
2- Sketch free diagram for each block (now their acceleration is known) and write 2nd law of Newton for each of them. Just remember, static friction is just f (an unknown value, which can be obtained from the two equations you just wrote (Newton 2nd law).