How did Islam spread in the Arabian peninsula, in particular Makkah and Medina?
Islam did not start it's spread via military conquests, although they would have occurred due to various reasons.
Muhammad is a troublemaker and warmonger, and started the conflict himself, in both Mecca and Medina.
He incited troubles, when he first began preaching to people to destroy worship of pagan religion, in Mecca. He was first to threatened other people's rights to worship as they please.
That's the reason why he was eventually driven out of Mecca, because he can't control himself.
When he was in Medina, he caused more trouble, like driving the Banu Qaynupa out of their homes, in 624, and stealing their properties.
And he started a war with Mecca, because he began resorting highway robbery, he and his followers were frequently stealing from merchant caravans, in 623-624. In one of these raids, in 624, one of caravan guard was killed, by one of Muhammad's men; did Muhammad regret this death? Did he have the killer arrested?
This is not a defensive action or self defence, this is pure vengeance, and Muhammad was never peaceful person. He acted like a robber baron, mafia, or warlord.
He approve of assassinations done in his name and in name of his religion and his God, which make his religion stained in blood with murders. Did he have these assassins arrested and tried? No. He didn't. According to the biographers he praised them for their taking initiatives in committing murders in murdering on his and Allah's behalf.
In 630 after the Banu Qurayza surrendered after the siege, he allowed a dozen men to be spared, because they converted, the rest of them were killed and their omen and children enslved. Is that not compulsion?
When Muhammad marched into Mecca, without further fighting, he had ten or so men executed without any trial. Is that law or justice, or were they revenge killings for his exile? Look like the later is true.
And he got what he wanted, destroying other people's by destroying idols. So much for freedom of religions.
Ta'if was another city, that surrendered, to Muhammad, but the only surrender he would accept, was them all converting. Convert or face death or slavery. That's another compulsion.
Muhammad's army attacked Byzantines first, when they entered Byzantine land in Syria. So it was Muhammad who drew first blood. Byzantines were simply defending the Ghassanids living in their territory; the Byzantines had the rights to defend the Ghassanids, because they were Byzantine ally in the recent war against Sassanid Persia. The Byzantine victory was indecisive, so the Muslims came back with a larger army after Muhammad's death, and conquered Syria, and Egypt, in revenge for their previous defeat in 632.
My point in this, is that Muhammad and Muslims for motivation in all their wars have been always revenge and not just territories and plunders.
Revenge is never a peaceful acts, and it is certainly not lawful or for justice.