McCoy created a new timeline when he saved her. But Kirk and Spock were stuck in (the 23rd century of) that new timeline, with the only way to get back being to undo the damage caused by McCoy.
Albeit, technically they may not have gone back to their original timeline, but created a new, extremely similar one. In Star Trek, sometimes alternate timelines converge and sometimes predestined timeloops exist, so it’s hard to say which one happened.