Remember, in order to prove a statement of the form "if A, then B", what you do is assume A and derive B from it.
In our case, A is the statement S(k): "in any group of k people, everyone has the same age", and B is the statement S(k+1): "in any group of k+1 people, everyone has the same age."
Step 4 says that all we have to do to complete the proof is assume A is true and try to derive B from it. Therefore, it is legitimate to use A and treat it as true in the process of proving B.
That's exactly what we're doing here. At this stage in the proof, we have two things are disposal:
Within G, there happens to be a group of k people (namely, the group of everyone in G except for the one person P).
Since we are operating under the assumption that, in every group of k people, everyone has the same age, it follows that everyone in this smaller group within G has the same age.
And, it is perfectly legitimate to use this knowledge about this smaller group within G to try to show something about G itself, which is what the subsequent steps in the proof attempt to do.