'Had to' is the past form of 'must' and expresses past obligation or necessity. 'Must had' and 'must to' are grammatically incorrect. 'Didn't have to' would mean there was no obligation, which doesn't fit the context where the speaker needed to take the next train.