I also took into consideration, that earlier in the episode, Kirk took a hardline position that Tracey must be arrested for violating the PD.
McCoy and Spock made some compelling arguments why arresting Tracey wasn't a good idea, although Spock simultaneously egged Kirk on to arrest Tracey.
McCoy: Now wait a minute. He lost his ship and his crew, and he found himself the only thing standing between an entire village of peaceful people.
Spock: Regulations are quite harsh, but they're also quite clear, Captain. If you do not act, you will be considered equally guilty.
McCoy: Without a serum, we're trapped here with the villagers. Now why destroy what's left of the man by arresting him?
Spock: I agree that formal charges have little meaning now.
...
Kirk: The fool. Starfleet should be made aware.
Kirk disregarded the mitigating circumstances.
Even as a practical matter, by arresting Tracey at that point in time, he backed Tracey into a corner. He turned Tracey into an adversary. He could have put the legal aspects aside, at least for the moment, and concentrate on working with Tracey to deal with more pressing matters, like survival.
Getting back to the legal aspect of the situation, Kirk applied a strict standard on Tracey regarding the PD. But when it came to his own PD violation, he applied a different standard.
Again, if Kirk hadn't said "they must apply to everyone or they mean nothing", the double standard wouldn't have become so blatant.