The four gospels record the life, death, and resurrection of Jesus. There are multiple events that are shared and reported among the four gospels.
This is one of those events.
Note that Wikipedia mentions that this could be two separate events, but it is commonly accepted to be one event, shared among the gospels.
If we look at the four gospels, we see Jesus crucified, buried, and resurrected four separate times. The events leading up to his death are similar including four last suppers, four records of trial, etc.
Now, we can presume that he did all of these events multiple times, or we can (rightly) move forward with the understanding that these records are four viewpoints of the same events.
In all four books, Jesus was anointed with expensive oil. Two books show he was anointed on his head, two show he was anointed on his feet. More than likely, he was anointed on once on both his head and his feet.
Mark records the estimate of the oil at 300 denarii. A denarius is valued at 10 asses. A donkey, in modern currency, is worth around US$1000-$2500. This makes the oil worth 3,000 asses, which is, in today's money, $3,000,000 - $7,500,000.
I don't know about you, but I rarely come across any single item that's worth multiple millions of dollars.
Yes, Jesus might have been anointed twice or four times. But if we use just the tiniest amount of common sense, it seems pretty obvious that being anointed with a $3million oil was not a common event. Therefore, it's extremely safe to assume that this was really simply one event.