The answer to this lies in how the book treats the timeline. Time travel as used in Prisoner of Azkaban seems to follow a one-pass method.
There are a few different ways of handling time travel in fiction, but for the purposes of this answer only one distinction is particularly relevant; that being, whether it is a one- or two-pass timeline.
A two-pass timeline is like that of Back to the Future. In a two-pass timeline, we first see the original, unaltered events, and then later see them in the second timeline with the changes enacted by the time travel.
A one-pass timeline is subtly different in that we are never shown the timeline that existed without the effects of the time travel, if it existed at all. One-pass timelines don't occur very often in fiction, as they can be quite confusing to the reader.
The trick here is that <PERSON> writes our first look at the scenes in question with our viewpoint from a distance, carefully obscuring the events. 489
During the execution, the trio hear the swing and strike of the axe and <PERSON> sobbing and draw the sensible conclusion, as do we as the readers. Then, when we learn about the Time Turner, we think that there is now the chance to go back and change the events.
What <PERSON> does masterfully here is trick us into thinking that we're looking at a two-pass timeline when it really is a one-pass timeline. The events of our first look at the timeline are actually perfectly consistent with the changed version; the axe still strikes, <PERSON> still sobs, the <PERSON> is still cast, but the context we were missing the first time through leads us to believe that these were the 'wrong' events, that they have to be changed. It's only the second time we see the events that we realize that the actual events worked out just fine, and it was just our limited knowledge that made us think they needed to be changed.
So if you're trying to wrap your head around how <PERSON> cast the <PERSON> the first time, instead try to make sense of this: there was never a version of that scene that didn't have both <PERSON> in it. 674