Historically most religions don’t really seek to expand. Pagan berserkers didn’t send out missionaries. Empires like Rome and the Persians let their conqured peoples keep their religions for this reason, they didn’t care.
With religions like Christianity and Buddhism, it’s probably a combination of factors. One, they started out as more of what we today would call movements - movements for peace, anti-imperialism, anti-caste or slavery, general reforms and so on. In the early days they also likely spread due to a growing dissatisfaction with capricious deities, in the manner that Christianity turns people off today.
Two, there is the evolutionary factor that religions that sent out missionaries, and who would take anybody could simply acquire more followers from larger geographical areas. What comes down to us are the variants that were more successful.
In addition to those two factors, sometimes governments made them official. In ancient times city states, clans, and warlords would use deities as a sort of banner to unite people under. When Christianity started becoming popular, they used things like different interpretations of the trinity as their banner. When Christianity started becoming potentially threatening, Constantine made it the official religion of Rome, which neutered it.