Basically this question, and when do you pick it, maybe not even role but a side.

Personally for me, I wait till about mid game by then I have a fair number of options and I look to see who is winning, if mafia is failing terribly I will most likely side with town or go neutral, is mafia is either winning, doing decent, or in a tie situation, i go mafia cause that gives me a higher chance of winning because i just increased the mafias numbers by one (which is a big deal if you say increased the town's numbers by one, which wouldnt be a huge deal unless you picked a really important role)