Matthew 20:1-13 and Mark 11:1-11 mention Jesus' entry into Jerusalem and that he was afterwards anointed in Bethany -- Matthew 26:6-16 and Mark 14:3-11.
John however mentions that Jesus was anointed in Bethany (John 12:1-8), and after this he entered into Jerusalem (John 12:12-15).
These records about the anointing of Jesus in Bethany and his entry into Jerusalem are also in harmony with each other and they complement each other rath than being contradictory. The apparent contradiction comes about with the false assumption that the records each speak of the same identical events, i.e. an identical anointing and an identical entry into Jerusalem. But the gospel records mentioned here do not describe an identical situation, but rather speak of different anointings and also two different entries into Jerusalem. These are similar situations and events, but not identical ones.
In order to understand the sequence of events, it is necessary to carefully note the references made in the gsopels as to times and places. If we then take the really identical situations as chronological orientation marks, the records in the four gospels can be arranged chronologically correct, and we recognize that the mentioned anointings are two different events which actually happened several days apart from each other. Between these two anointings there were on two consecutive days two entries into Jerusalem. These entries differ in several points, for example in the number of animals which were used by Jesus.
The sequence was as follows:
1. John 12:1-11: 6 days before the passover (i.e. on 8 Nisan); a meal in Bethany at the home of Lazarus; Mary anoints Jesus' feet; Judas is agitated about it; many follow Jesus; the high priests determine to also kill Lazarus
2. John 12:12-19; Luke 19:29-44; Mark 11:1-11: On the next day (9 Nisan), Jeses enters Jerusalem on a colt; weeping over Jerusalem; disciples spread the news in Jerusalem; Jesus went into the temple and looked around, then in the evening he returned to Bethany.
3. Mar 11:12-19; Matthew 21:1-17; Luke 19:45-46: On the next morning (10 Nisan) entry into jerusalem on two animals; money changers and merchants driven out of the temple, teaching in the temple, in the evening again leaving the city.
4. Matthew 21:18 - 26:5; Mark 11:20 - 14:2; Luke 20:1 - 22:2 On the next day (11 Nisan), Jesus was preaching in the temple; controversy with the religious leaders; after leacing the temple he spoke with his disciples on the mount of Olives, in the evening return to Bethany.
5. Matthew 26:6-13; Mark 14:3-9 That evening Jesus attended a meal at Simon's house in Bethany; an unnamed woman anointed Jesus' head; this time not only Judas but the disciples are agitated about it; Judas then leaves the group to go and betray Jesus.
We can see from this example how wonderfully accurate and reliable the records in God's Word are. What we are told in the Word of God is free of contradictions, it is logical and actually for the most part easy to understand if we are diligent to read accurately what has been revealed in the Scriptures. Perhaps the greatest hindrance to a correct understanding is the immense influence of traditions and well known but false doctrines, because we, being influenced by these, then read inaccurately and even endeavour to take such a presupposed false opinion as measure for truth and we try to harmonize the record in God's Word with our opinion. Such an approach is doomed from the beginning to end in failure, only a putting aside of the false traditional teachings and a unreserved turning to the the truths revealed in the Bible make possible that we gain a true knowledge of what God has revealed to man in His Word.