The following reasons detail why European countries colonized countries in Asia and Africa:
Resources: There were an incredible variety of resources produced around the world that fed into the European industrial machine. Indonesia and Malaysia had rubber trees, Central Africa produces coltan and other metal ores, the Persian Gulf is known for petroleum, etc. The European powers wanted to gain access to these resources to power their industrial rise.
Strategic Territory: Numerous colonies had specific strategic locations, such as Egypt with the current Suez Canal, Morocco with the Straits of Gibraltar, India because of its massive spice production and outlets to the Indian Ocean. Indochina was close to the unconquerable Qing Empire. Many colonies were chosen specifically based on where they were and how effectively defense could be maintained by holding those positions.
Christian Evangelism: Many Europeans believed quite strongly at the time that their technological success was correlated with their belief in Christianity. In their view, non-Christians like the Muslims, Hindus, Buddhists, etc. were hindered by the mentalities present in their religions from being technologically astute. In order to "help" these people to becomes more modern and more worldly, it was "necessary" to teach them the proper way to believe so that they too could succeed. Sometimes this evangelism was benign. At other times, it erupted in full-scale conflict, such as the Sepoy Mutiny of 1857.
White Man's Burden: Europeans were fascinated with the philosophy of J.S. Mills Jr. and Rudyard Kipling who believed that there was really only one track to humanity and each person was on this track to ultimate advancement. As Europeans were further along this track, it was "incumbent" on them as act of generosity to help those who were not as technologically or "culturally" advanced. There were campaigns across Africa, Asia, and Australia to "Europeanize the Natives" so that they would be "able" to progress properly.
Labor and Military Augmentation: The colonies, especially in Asia, had very high populations relative to European countries. This allowed them to add large numbers to their labor force and to create new military divisions from this large population.
Appearance of Power: European Leaders ascribed power and dominance to those countries who were able to amass a large number of colonies, especially if they were in coveted or strategic locations.