There has never been a canon stated reason for the whisker marks in the story or by creator Masashi Kishimoto himself, so the acquisition of the whisker marks is still undetermined.
However, there are popular fan theories, like the other answers people have given here, for example. Due to the fact that the only explanations so far have been fandom speculation, the wiki citation given in one of the other answers has since been removed onfrom his officialwiki page for lack of confirmation or sources to back it up, if that clears up any confusion.