In the case of the 365s, they were really simply in the wrong place at the wrong time. The combination of Covid timetable reductions and the reduction of the Gatwick Express service meant there were some spare 387/2s available, which allowed the remaining 365 diagrams to be covered. Meanwhile over-ordering of new EMUs in recent years combined with few electrification schemes has meant there is a lack of work for EMUs in general.
I have heard it said there’s a little more to it, specifically that the leasing cost for these units had been excessively high. I’ve no idea of the authenticity of this, however it would explain why GTR seem to have been rather keen to get rid of them, whilst still retaining two very much older fleets running south of the river.
As for the Mk4s, similar reasons in that a lot of new trains have been ordered. In this case it’s a little different, as a conscious decision had been made to replace the East Coast high speed fleet, so they have essentially been subject to a straightforward fleet replacement. By contrast the 365 story is much more complex.