Matthew writes that, during one of his confrontations with the Pharisees, Jesus said that those who are not with him are against him. This is Matthew 12:30:
In a seperate incident, regarding a man using the name of Jesus to drive out demons, Jesus says what appears to be the opposite. This is Mark 9:38-40:
The first thing to note is that, from a strictly logical point of view, this is not a contradiction at all. If everyone who is not with you is against you, then everyone who is not against you is with you. Either sentence is sufficient to rule out the possibility of people being neutral, and thus, to divide people into just two mutually exclusive groups: for and against.
Usually when someone says something like what Jesus says, he is really saying that those who are not actively involved are either for or against. Understood this way, the meanings become:
However, I don't think it's necessary to read the passages in this way. Instead, the strictly logical approach above works fairly well.
Furthermore, the context in which the two claims are uttered is quite different. In Matthew (and also Luke 11:23), Jesus is addressing his enemies, whereas in Mark (and also Luke 9:50), Jesus is addressing his friends. In the latter case, it's reasonable to think that the change in emphasis is to ensure that the disciples do not think that everyone is their enemy.