-Spock jettisons Kirk (This makes no sense whatsoever. Surely they have a brig? Or just a empty closet? This is not plausible behaviour. This was a hostile planet, what if that monster had eaten Kirk?)
Spock had been emotionally compromised.
-Kirk happens to land on same planet than old Spock was jettisoned earlier, they happen to meet, and they happen to find -the only other person on the planet, who happens to be the person who can build the highly implausible warp transporter.
Coincidence happens in a lot of Star Trek.
-Kirk makes Spock angry and assumes command, though he was relieved from command earlier...
Spock hadn't had time to file the paperwork. So Kirk was still technically first officer.

I've had to come up with a lot more complicated explanations for Star Trek over the years.