The question is whether the meal at the house of Simon the leper took place six days before Passover, as John 12.1 indicates, or two days before, as Mark 14.1 and Matthew 26.2 write.
The three evangelists report the same episode, but their time markers do not coincide, which shows that they do not take the same starting point.
John gives the actual chronology: the Messiah Jesus arrives in Bethany six days before Passover, and it is within this setting that the anointing takes place. Mark and Matthew, on the other hand, do not date the anointing but the plot of the authorities.
Matthew 26.1 5 confirms exactly the perspective of Mark: the Messiah Jesus finishes his discourses and announces his imminent Passion, and then Matthew reports that the leaders gather to plot "two days before Passover."
Like Mark, Matthew then places the anointing in an inserted account, with no date of its own, between the plot and the betrayal by Judas. The two Synoptic Gospels thus use the same narrative technique: they do not seek to place the anointing in time but to set it, as a literary device, between the hatred of the leaders and the betrayal by the disciple, in order to create a theological contrast.
The marker "two days before Passover" concerns the plot, not the meal at Simon's house. The meal could therefore very well have taken place several days earlier, as John reports, but Mark and Matthew move it in order to heighten the dramatic tension.
This editorial freedom is also explained by the context: if Mark writes very early, between AD 46 and 50, in a period of persecution, he keeps the woman anonymous so as not to expose a Christian woman who was still alive, and Matthew, who follows the same tradition, does likewise. John, writing much later, at the end of the first century, in a context where the witnesses have died, can name Mary of Bethany and restore the exact chronology.
Thus the three evangelists speak of the same event, but Mark and Matthew position it as a literary device to underline the contrast between the love that honors Jesus and the hatred that delivers him up, while John gives its historical dating and the precise identity of the woman. The apparent discrepancy between the chronologies disappears as soon as one understands that Mark and Matthew date the plot, whereas John dates the meal.