Different countries have been established in different ways. Some, like Australia or New Zealand, have been consciously created by people coming from other countries. Others, like Nigeria and other countries that were once ruled by imperial powers, have been created by the orders of their imperial rulers.
With countries that came into existence "naturally" it was generally a process of agglomeration of smaller political entities. This typically happened through force. There would be a few bands of people and one would take over the others, making a mini-state in a given region. Then one little state would conquer another and so on. In Europe, at least, this process continued up through the feudal era until countries started to have more centralized governments during the High Middle Ages.
Where exactly ?