You are continuing to use the Work-Energy Theorem. This is easier to apply to mechanical problems. In electrical or thermal problems it can be difficult to identify what the forces are (as in your last question) - hence what work is being done - and what the kinetic energy is (current? heat flow?). I find it easier to use the Law of Conservation of Energy : energy into "the system" = energy out + increase in internal energy.
You have not defined "the system". Because of this you have counted one source of work done by/on "the system" twice. As you note, the positive work done by the capacitor on the external agent is equal to the negative work done by the external agent on the capacitor. These are just the 2 sides of the same energy transaction. If you define the capacitor as "the system" then you only need to look at one of these to work out how the internal energy of the capacitor is changing. But if "the system" includes the capacitor and the external agent then the internal energy does not change, because the system is doing work on itself.
Probably because you are not using Conservation of Energy, your equation does not take account of the change in internal (ie stored) energy of the capacitor(s).
You are assuming that the resistive forces which dissipate heat in step (i) are still present (or significant) in steps (ii) and (iv). However, I think the question intends that such losses are now negligible - ie the energy which was dissipated as heat in (i) is now dissipated instead as work done against the external agent in (ii) and (iv). This is the fault of the problem. Using the spring analogy, in (i) the spring is allowed to oscillate so that it dissipates energy due to air resistance or hysteresis before reaching equilibrium, whereas in (ii) the spring is slowly lowered to the equilibrium position by the external agent so the air resistance or hysteresis losses are negligible.
Your Solution
The capacitor is "the system". Your equation should read : $$\text{work done by all external forces = increase in internal energy}$$ or $$\text{work done by external agent} +\text{work done by battery} + \text{work done by resistive forces} =\text{ increase in internal energy}$$
The external agent and the resistive forces do negative work on the system (they remove energy). We are probably expected the assume that the current is so small (because the slab is inserted so slowly) that the resistive forces do negligible work. Therefore $$\text{ work done by battery} = \text{ work done against external agent} +\text{ increase in stored energy}$$
Work done by battery is $(k-1)CV^2$ as you wrote. Increase in stored energy is $\frac12 (k-1)CV^2$. So work done against external agent is $\frac12 (k-1)CV^2$.
My Solution
(i) The battery charges the two capacitors to potential difference $V$. The total capacitance is $3C$ and the total charge stored is $Q=(3C)V$. So the work done by the battery is $(3C)V^2$.
However, the energy stored in the capacitors is only $\frac12 (3C)V^2$. The other $\frac12 (3C)V^2$ of the work done by the battery has (presumably) been dissipated as heat in the wires.
I say presumably because we don't really know how the extra energy was lost. If there was no resistance in the connecting wires then charge would oscillate and eventually lose energy as electromagnetic radiation.
(ii) This is the same as your previous question : dielectric is inserted into a capacitor while the battery is connected. The capacitance increases by $(k-1)C$ whereas the voltage is the same, so the energy stored increases by $\frac12 (k-1)CV^2$.
However, as in (i) the battery has done work $(k-1)CV^2$ to increase the charge stored. The missing energy $\frac12 (k-1)CV^2$ has been removed by the external agent. If the external agent did not remove this energy the slab would continue to oscillate and charge would flow back and forth in the circuit until the "kinetic" energy was removed by resistive heating or EM radiation or friction between the slab and the conducting plates.
The energy stored in the $2C$ capacitor is not affected, because the capacitance and voltage remain the same. It is still $\frac12 (2C)V^2=CV^2$.
(iv) The battery is removed. The total charge on the two capacitors remains constant.
Before the battery is removed the total capacitance is $(k+2)C$ so the total charge stored is $Q=(k+2)CV$. The stored energy is $\frac12QV=\frac12 (k+2)CV^2$.
When the slab is removed the final capacitance is again $3C$ so the energy stored is $$\frac{Q^2}{2(3C)}=\frac{(k+2)^2}{6}CV^2$$ The increase in stored energy is $$\frac16 (k+2)^2 CV^2-\frac12 (k+2)CV^2=\frac16 (k-1)(k+2)CV^2$$
This is the work done by the external agent to remove the dielectric slab.