In Matthew 12:30 Jesus speaks against critical Pharisees who explain him with reference to Beelzebul. He then points to the need of a conscious choice for Jesus. One may not evade this: whoever does not choose for Jesus chooses against God. In Mark 9:40 the situation is different: at issue now are internal relationships, in connection with the approaching suffering. This verse therefore is not in conflict with Matthew 12:30.1
40 For the one who is not against us is for us.