Islam is a religion of peace but it is a religion of justice so when other nations attacked Islamic countries, of course the countries defended themselves and they defeated the attacking people.
Muslims spread from Egypt to the West until it was reported that they had reached the Atlantic Ocean.
Here we see what happened when they reached Spain and the Islamic Golden Age.