The Guru's son Gobind Rai was a boy when his father was taken to Delhi, and he succeeded as the tenth Guru. Twenty-four years later, at Anandpur, he founded the Khalsa, and the connection between the two events is drawn explicitly in the Sikh tradition and in the writings attributed to him.
The problem the founding addresses is visible in the manner of the father's death. The Sikh community had been persecuted repeatedly and had no organised, identifiable body able to withstand it, and the tradition records that even the disciples who witnessed the execution did not immediately claim the body for fear of being identified. The Khalsa answered that directly: initiated Sikhs would be recognisable, by uncut hair, by the articles of faith they wore and by the names they took, and would be bound to a discipline that included the defence of the community.
Being identifiable is the pivot. A persecuted group ordinarily conceals itself, and the founding of the Khalsa did the opposite, requiring visible marks that could not be set aside under pressure. That decision, taken by a Guru whose father had been executed in public, is a deliberate reversal, and it is the reason the two events are read together in the tradition rather than separately.