The positions are elected by a vote at the supreme soviet assembly, those positions are elected by the soviets (councils) below the assembly, and those are elected by the soviets below that, and so on down to the lowest level where the local constituents vote.
In the party it's generally considered a "duty" though, especially among those that participated in the revolution like Stalin who treated loyalty to the organisation, self-sacrifice and subordination to it as a significant and necessary part of what made the revolution succeed. Thousands of people literally sacrificing their whole lives for the goal.
As such, Stalin wouldn't break a decision of the assembly just as he wouldn't want anyone else to. If they said they still needed him in his post he did his duty and stayed despite not wanting to.
He largely held equal powers to everyone else on the Council of Ministers, the position of Chairman didn't have special powers. The General Secretary role of the party was invented by Lenin with the intention of it being used to break opposition in the party (perform purges). Once Stalin had successfully performed his purges and prevented split in the country/civil-war he saw the position as having completed its purpose and wanted rid of it, he didn't like the cult of personality around himself and wanted people to view the government in a collective capacity rather than an individual leader kind of way. That's obviously not what ended up being the perception though. Lots of hero worship got in the way.
Has the fastfetch dev ever mentioned why they use the infinity symbol? Don't want to find out later on that it's a dogwhistle.