From what I can gather:
Enterprise assigned to observe planet Nibiru and the natives before it blows up.
Kirk disobeys orders and decides to save the planet but I assume Spock says they cannot reveal themselves to the natives and Kirk goes along with it.
Planet is saved but Enterprise revealed.
Kirk loses command because of breaking the prime directive, disobeying orders & falsifying the logs?
It's a bit ambiguous, I admit, but here's my take on it:
is on a routine survey mission when they stumble onto the crisis on Nibiru. Saving the planet wasn't on the agenda, but it wasn't expressly forbidden either. Kirk, acting on his own initiative, decides to intervene. Spock agrees to go along with it, provided they don't break the Prime Directive by revealing themselves to the natives.
But the best-laid plans . . ..
Later, a frustrated Pike complains that Kirk was just supposed to be on a goddamn survey mission, but the real issue seemed to be that he let himself be seen by the natives. I didn't get that he had been ordered to let the natives die.
How would Pike have reacted if the plan had gone smoothly and Kirk had saved the planet without the natives being any the wiser? Hard to say.
I think the confusion here reflects a larger confusion as to what exactly Prime Directive covers--which, alas, carried over into the new movie.