Mark 1:12-13 describes what happened to Jesus immediately after his baptism:
However, the description of the baptism in John's gospel is followed by John 1:35-36:
But there is no real contradiction. The preceeding passages in John do not directly describe the baptism, but rather give the Baptist's spoken account of the baptism. So, "the next day" refers to the day after John the Baptist gave this account, not the day after the baptism itself, which may have occurred months previously. The order of events is something like this:
| Mark 1:9 | ... Jesus is baptised |
| Mark 1:12-13 | ... Jesus enters the wilderness for 40 days |
| John 1:31-34 | ... Weeks or months after the baptism, John gives an account of it |
| John 1:35-36 | ... The day after that, John points out Jesus |
(For the avoidance of confusion: John the Baptist and John the author are different people.)