The common interpretation was that Stalin was having Yezhov taken care of because he had served his usefulness but was now dangerous because of his position, what he knew etc. In this interpretation Stalin/Yezhov essentially did that same thing to the former head of the NKVD, Yagoda. Robert Conquest argues this in "The Great Terror".
Some variations give more agency to Beria in the removal of Yezhov and treat it as part of internal power politics. IIRC Simon Sebag Montefiore presents this in "Stalin: Court of the Red Tsar".
A slightly more alternative take on things appeared in J. Arch Getty and Oleg Naumov's "The Road to Terror", and I think is also repeated in their biography of Yezhov also. Basically the argument is that Yezhov was cracking under the stress of his job as NKVD chief (recall that not finding enough enemies was taken as proof of being an enemy yourself) and starting to get too deep into alcohol etc. as a result. This dissolute behaviour (which ironically was the sort of thing denounced amongst early victims of the purge) along with a perception that the purge had gotten out of control under Yezhov's leadership resulted in his fall from grace and own subsequent purging. In this interpretation his later job as Commissar of Water Transport wasn't part of an elaborate plot to get him away from the NKVD, but an attempt to find him a more peaceful job.