The Quran says fight those who fight you, so one answer is that the early muslims were attacked and defended themselves. They then removed the threat of further attacks by removing the cause of such attacks, the head of the snake, or, as the Quran describes, the command centres.
8:12 Recall that your Lord inspired the angels, “I am with you. So make the believers stand firm. I will instill awe in the hearts of the unbelievers.” Then (O believers) launch a swift strike to disillusion their command and scatter their soldiers. [Fawq al-a’naaq and Kulla banan are exactly similar allegories as we find in 47:4. No commander, during active combat with swords and arrows, would order his soldiers to aim only for ‘above the necks’ and ‘at every one of their finger tips’. Would not that be a sure way to lose the battle?]
Another answer is that the Quran says that if the muslims had not intervened, then churches etc would have been destroyed which brings us to another Quran justified reason for fighting and that is to stop oppression.
22:39 Permission to fight is granted to those against whom war is wrongfully waged. God is Able to support them -
22:40 Those who have been evicted from their homes unjustly, for no reason other than saying, "Our Lord is God!" For, if God had not enabled some people to repel others - temples, monasteries, churches, synagogues, and mosques - where the Name of God is oft mentioned, would have been destroyed. And God will certainly help those who help Him. God is Mighty, Powerful.
22:41 They are the ones who if We give them power in the land, establish Salaat (the Divine System), and set up the Just Economic Order (in which wealth circulates freely to nourish every member of the society, and the basic needs of all individuals are taken care of). They promote the Permanent Moral Values and discourage what the Qur’an forbids. And in their governance all affairs are decided according to God's decrees (given in the Qur’an. 5:44-47).
It is inconceivable that the early main companions, AND PLEASE DO NOT SAY I AM IDOLISING THEM, would have engaged in acts contrary to the Quran as they would have been chosen by the Messenger and made into the best of peoples by the Quran. The historical fiction of their lives were written in the Abbasi period who massacred the ummayads, but when you had Abdur Rehman, starting the golden age in Spain after his family were eliminated, anything and everything is suspect.
We know what happened after the early muslims left the scene, there were good and bad muslim leaders, and the rest is history.