Wa `alaykum As-Salamu waRahmatullahi wa Barakatuh.
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
Answering your question, Dr. Muhammad Salama, PhD, Islamic Studies in English, Associate Professor at the Faculty of Islamic Sciences al-Madinah International University (Mediu), states:
The confusion you have regarding this issue is a result of misunderstanding the proper order of events in this regard.
Imam Al-Bukhari reported on the authority of Ibn `Abbas that he said: The Prophet (peace and blessings be upon him) came to Medina and saw the Jews fasting on the day of `Ashura’. He asked them about that. They replied, “This is a blessed day when Allah rescued the Children of Israel from their enemy. So, Moses fasted this day.” Then the Prophet (peace and blessings be upon him) said, “We have more claim over Moses than you.” So, the Prophet fasted on that day and ordered [Muslims] to fast on it. But the Messenger of Allah (peace and blessings be upon him) observed fasting on that day even before his migration to Medina.
Both Al-Bukhari and Muslim reported on the authority of `A’ishah that she said: Quraish used to observe fasting on the day of `Ashura’ in the jahiliyyah (pre-Islam period of ignorance) and the Messenger of Allah used to observe it. Then when he migrated to Medina he observed fasting it and commanded [Muslims] to fast on it.” This should cause no confusion because it is reasonable that both parties fasted on the same day but for different reasons.
On the other hand, authentic narrations tell us that the Messenger of Allah liked in the beginning of his migration to act like the People of the Book who were closer to Muslims than the polytheist pagans. Then he later started to distinguish himself and his followers from them and issued various commands and instructions to emphasize and highlight such distinction. One of these commands was to distinguish fasting on the day of `Ashura’ by fasting another day before or after it.
Allah Almighty knows best.