As-salaamu 'alaykum!
2:216 Fighting is enjoined on you, and it is an object of dislike to you; and it may be that you dislike a thing while it is good for you, and it may be that you love a thing while it is evil for you, and God knows, while you do not know.
2:217 They ask you concerning the sacred month about fighting in it. Say: Fighting in it is a grave matter, and hindering (men) from God’s way and denying Him, and (hindering men from) the Sacred Mosque and turning its people out of it, are still graver with God, and persecution is graver than slaughter; and they will not cease fighting with you until they turn you back from your religion, if they can; and whoever of you turns back from his religion, then he dies while an unbeliever– these it is whose works shall go for nothing in this world and the hereafter…
All narratives in the Qur'an should be an exemplum for you to take heed.
We read ahead...
Did you not note the leaders of the Children of Israel after Moses, they said to their prophet: "Send us a king that we may fight in the cause of God;" he said: "Are you not concerned that if fighting is decreed for you, you will then not fight?" They said: "And why should we not fight in the cause of God when we have been expelled from our homes along with our children." So it was, that when fighting was decreed for them they turned away, except for a few of them! God is fully aware of the wicked. (2:246)
The Prophet (s.a.w) was expelled:
If you do not help him, then God has helped him. When those who rejected expelled him, he was one of only two, and when they were in the cave, he said to his friend: "Do not grieve, for God is with us." So God sent down His tranquility over him and He supported him with soldiers that you did not see, and He made the word of those who rejected be the lowest, and the word of God be the highest. God is Noble, Wise. (9:40)
The began the hostilities:
Would you not fight a people who broke their oaths, and obsessed to expel the messenger, especially while they were the ones who attacked you first? Are you concerned about them? It is God who is more deserving that you be concerned with if you are believers. (9:13)
Wa as-Salaam!