When things are going to hell, and a strong leader is available who they think can right the ship, no one gives a **** about strict succession laws. Real history is full of cases of people with weak claims seizing power because they were vastly superior to the people with the legal claim.
Jon is also not Lord of Winterfell, Sansa is the Lady of Winterfell. She tries to give the title to Bran as the rightful heir, and he declined. Jon is (or was) King in the North, which there has only been one of in hundreds of years and he was appointed by the Lords. I don't remember them establishing any kind of order of succession for that title besides naming a new one, which the Lords did when they named Jon Snow King in the North.