I'll answer the first bit about how Stalin became the leader. Stalin's rise to power is a very interesting story. Stalin was one of the key early leaders in the Bolshevik party during the Russian Revolution (1917). At the time the leader of the party was Vladimir Lenin who inspired the Bolshevik party to take power in the October revolution. Stalin was an important figure in both the party and the new government. He was made minister for nationalities in the government and was appointed General Secretary of the party (that was the person in charge of the organization and running of the party). It was this second position which allowed Stalin to take power. He was never seen as a deputy leader during Lenin's lifetime and was by no means one of the most charismatic or popular of the early Bolshevik leaders. He was a poor public speaker who was sometimes seen as relatively unintelligent (compared to brilliant theorists like Lenin, Trotsky and Bukharin who led the party) but was highly regarded as a bureaucrat. One of his rivals called him "a grey blur, a mediocrity". But because he was so ignored he was totally underestimated and was able to use his position as general secretary to slowly build his power within the party, ensuring his supporters were appointed to important positions, making sure people owed him favours, taking control of the mechanisms by which decisions of the leadership were transfered to members etc.
Lenin was the head of both the party and the government and was the undisputed central leader but suffered a stroke in 1922 and died in 1924. So when he became ill a struggle developed between the other leaders about who would succeed him. Lenin himself had hoped that the party would not appoint any one leader and that a tradition of collective leadership would be maintained so he did not appoint a successor. So at the time he died there were basically 7 people who were leading the country who were all members of an institution called The Politburo (short for the Political Bureau) which headed the party. These were Kamenev, Zinoviev, Trotsky, Stalin, Bukharin, Rykov and Tomsky. None of them was "the president" or anything like that (the president of the USSR at this time was a man called Kalinin who was insignificant) and no one of them was the official leader, they all held prominent positions and all the key decisions were meant to be decided collectively between them. But the most impressive and famous of them was Leon Trostky. He had been seen as the second most important leader of the revolution since the beginning. He was the man who actually organized the October revolution and had then been made the Minister for War. In this position he built the Red Army and led the country through a very brutal civil war so he was extremely highly regarded. In addition to all that he was a famous writer and thinker. So if anyone was going to emerge as leader it looked like it would be him. But Trotsky was hated and feared by some of the other leaders especially Zinoviev and Kamenev. So these two secretly approached Stalin and made an alliance with him (which is called the Troika). They all agreed to act together against Trotsky. Stalin used this alliance to outmaneavure and defeat Trotsky gradually defeating him in prominent votes and removing his supporters, and ultimately Trotsky himself, from key positions while using his power as general secretary, all the time, to build his own power base.
When Trotsky had been defeated the alliance between Stalin, Zinoviev and Kamenev broke apart as they gradually came to realise that Stalin was the greater threat. Now Stalin switched sides and formed an alliance with Bukharin. I won't go into all the politics of the time, which is complicated, but basically its important to understand that there were huge differences of opinion between all the leaders about lots of issues but most importantly about how the country could transition towards socialism. Bukharin represented "the right wing" of the party- he believed that a semi-capitalist system should be maintained for a long time and that the government should support small scale independent farmers in the countryside. Trotsky represented "the left wing" (his group was officially called The Left Opposition). They believed that the government should take more of a role in the economy, should try to industrialise the country and should build collective farms in the countryside. So Stalin now sided with the right against the left. In return Bukharin decided the policy of the government. Zinoviev and Kamenev desperately tried to resist Stalin and formed an alliance with their former enemy Trotsky but they were all defeated by Stalin's control of the party machine.
But once he had defeated them he now turned on his new ally Bukharin. In 1927 Stalin made a sudden shift and totally abandoned the policies of the right, taking on the policies of Trostky, who he had defeated, but making them much more extreme. All the other leaders endorsed policies based on their own beliefs but Stalin simply switched policies whenever it suited him in order to take power. He now used his control of the party, which was by this time, very advanced, to defeat his one remaining rival Bukharin (the other two members of the 7 man politburo Rykov and Tomsky were both allies of Bukharin). All the time this power struggle had been going on the party had been becoming more and more dictatorial. It had originally been quite democratic but gradually it became impossible to voice alternative opinionr, or to organize an opposition to the ruling group or even to openly criticise the official policy. So by the time Stalin faced Bukharin his rival couldn't even organize an open opposition.
Once Bukharin was defeated, in 1928, Stalin had total control over the party and the state. In the process he had created a party culture where it became impossible to voice opposition or to challenge the leader (which was entirely new, Lenin had never ruled like this). Interestingly Stalin never actually made himself the official leader. He did not take on the post of "president" which remained held by Kalinin, or the role of Prime Minister (which was held by one of his allies Molotov). Officially he only ever remained the General Secretary of the Party. But he had become recognised as the undisputed ruler of the country and would be unchallenged until he died in 1953.