If I understand correctly, Stalin gained power by being appointed in an seemingly innocuous role in government largely like an HR manager, and filling powerful roles with his allies. When Stalin passed, it seemed likely that his successor would be Beria who headed the NKVD. What caused Khrushchev to succeed Stalin instead?
seemingly innocuous role in government largely like an HR manager
This is not really correct. It is often claimed that nowadays, most by people who don't like Stalin or repeated claims by them.
Stalin was able to raise to this position because he worked with and for Lenin. While others like Trotsky and others put themselves as almost equal to Lenin, Stalin positioned himself as Lenin right hand.
The General secretary of the Party was designed to be a incredibly powerful position. Lenin created the position for Stalin, and explicitly gave it a lot of powers. It was well known to be a very powerful position when Lenin created it and was known that it would basically Stalin Nr.2 behind Lenin.
The General secretary had far more power then just HR management, that however was very a very powerful. It was the interface point with the secret police. It was responsible for enforcing party discipline. You had party operatives embed into all institutions, like the military. Basically the General secretary office, is where all the different power groups come together, even more so then the government.
When Lenin passed, Stalin was basically in control by default. In order for Stalin not to take over, somebody would have to remove him from his position and managed to do so.