The shock on the surface of the airfoil is a normal shock. It exists because the flow is supersonic, but is facing a back pressure such that it must shock down to subsonic. The flow does not turn at that shock because the surface is locally smooth.
Zoom in on the TE of the airfoil...
Flow regions 1 and 3 are supersonic. 2 and 4 may or may not be -- depending on the velocities and angles involved.
When flow regions 1 and 3 come together, they can't continue in a straight line. They must turn. That turning is accomplished by a shock.
The dotted line between regions 2 and 4 is called a slip line. Velocity across the slip line must be parallel (but not necessarily equal in magnitude). Likewise, pressure across the slip line must be equal. You can think of the slip line as a thin flexible membrane -- flow must be parallel to the slip line and if pressure was higher on one side, it would push the membrane until pressure was equal again.
So, you can see that the shock 'stops' at the trailing edge because it must be there to turn the flow. After the TE, there is no need to turn the flow.
There are situations where there can be a third shock in regions 2 & 4, but that is actually a small normal shock that serves to slow the flow down to subsonic.
EDIT: Adding some more details inspired by followup questions...
Even a thin boundary layer can complicate matters dramatically.
The shock causes an abrupt rise in pressure. This is an 'adverse' pressure gradient. Boundary layers tend to separate in adverse pressure gradients, so we often get separation at the point of the shock.
This separation bubble 'looks like' a bump in the surface to the flow outside the boundary layer. So you now need some turning where before you didn't. This causes the shock to change shape.
Shock-boundary layer interaction is really complex. You can see evidence of shock-boundary layer interaction in the Mach 0.84 to 0.98 images below.
Here is an extensive paper on the subject. Check out figures 9, 10, 11 in the paper. They focus specifically on the difference between an idealized inviscid transonic flow and a transonic flow with a boundary layer.
This paper calls part of this phenomena a delta shock (referring specifically to the compression waves at the front of the boundary layer interaction. I am less familiar with that name -- I usually see this whole arrangement (slightly bigger scale) referred to as a lambda-shock because it looks like the greek letter lambda $\lambda$.
The cartoon I drew before was an inviscid idealization. You can see how a little bit of boundary layer can significantly complicate matters.
Here is another idealized cartoon, but zoomed way in, 'just before' the shocks reach the trailing edge...
Here the upper and lower surface shocks are normal shocks, they meet the surface at 90 degrees and do not turn the flow. Also, the regions downstream of them (2 and 4) are now subsonic flows.
Now, the only streamline that needs to make a sharp turn at the corner is the streamline that lies exactly on the surface. Everywhere else, in a subsonic flow, the streamlines can make a gradual turn.
Of course, the limiting streamline can't make an instantaneous turn, so in the subsonic inviscid approximation, we actually have the limiting streamlines go to zero velocity at a sharp trailing edge like this -- that forms the aft stagnation point.
If this airfoil had a cusped trailing edge, things would be a little different.
Of course, all real flows have a boundary layer (even if it is thin), and the limiting streamline at the surface obeys a no-slip condition -- so its velocity is zero. The rest of the streamlines are able to make the TE turn without a singularity.
So, in our inviscid idealization, I would expect that the normal shock would stay a normal shock until it reached the trailing edge. At that point, like the limiting streamline in the subsonic case, the on-body streamline needs to instantly turn and it would do this by going to zero velocity at the trailing edge.
As the freestream Mach is increased further, the shock should lay over and become the oblique shock solution that we expect.
I'm not exactly sure what happens during that transition. Since this only applies to our idealized model, I'm not sure that those details are relevant at all. After all:
boundary layers happen. They allow the limiting streamline to turn and solve the stagnation streamline problem.
real shocks are not infinitely thin
real trailing edges are not infinitely sharp, they have some bluntness to them.
Myriad other complicating factors