How did a company gain control of territory? Isn't that a nations job?
Would it be like Microsoft or Apple going into Africa and buying up land and establishing a nation?
I know a bit about the BEIC in India.
How did they gain control of territory? Firstly, they wielded quite a bit of power even without bringing military action into the equation because if they chose to trade with an Indian principality and advise it, that principality would be much stronger, and would often be able to defeat its enemies. So in this way they made alliances with many Indian polities and, whether consciously or not, enacted a kind of 'divide and conquer' policy. They could call upon these allies to fight for them. They could also pay mercenaries as well. And finally, BEIC ships were armed, as most ships were at the time, so they could fight naval engagements and bombard coastal positions. Early on, when the British were conquering India, this is how they did it, with overwhelming 'soft power,' alliances, mercenaries, and naval power. Regular British troops were used very little, if at all. It's quite remarkable that such a large empire was established without what we think of as conquest, which is a vast army moving in and taking everything all at once, like the Germans did during WW2. But you see this everywhere during the colonial era. Tiny numbers of colonial administrators and soldiers would hold vast amounts of territory. What was going on was not simple military domination. It was a much more complicated relationship of exchange - economic, cultural, political, religious - that kept these empires together. An interesting example that illustrates this is the Japanese conquest of most of Europe's colonies in Asia during WW2. This was a true military conquest, a large army sweeping into multiple countries simultaneously with overwhelming force, and they toppled almost every single colonial administration in the region basically overnight. They couldn't withstand the assault partially because they were busy in Europe fighting already, but partially because they were never equipped to fight massive, modern wars in the first place. That wasn't what colonialism was about. It was much more complicated than simple military conquest.
Another thing you should remember is that the BEIC was very closely connected with the government. You can think of it as a crown corporation essentially. In fact, the early history of corporations in general is pretty inexorably linked to government action. The BEIC in particular was created in partnership with the government, many of its employees had worked for the government or would do so eventually, and the government protected it from failing, most strikingly in the rebellion of 1857, when the company almost lost control of India, and when, for the first time, the regular British army was called into the country to do heavy fighting. The company lost its mandate after the rebellion, but the fact that the British government threw its entire weight into making sure that India didn't fall shows just how linked the BEIC was to geopolitics.
Microsoft and Apple are not a good analogy because they're tech companies, and their business model is largely based on research and development. Of course, they do have to manufacture their products, but their footprint on the lay of the land is relatively small compared to the BEIC, which traded mostly in textiles and agricultural products. A better analogy would be something like the United Fruit Company, which does indeed have a history of meddling in local politics. It pushed the US government very hard, for example, to intervene in Guatemala when leftists gained power and threatened their business interests. Now imagine if this had happened in an era when it was viable and acceptable for the company to just hire mercenaries to do its dirty work, or use an existing alliance with another Central American state to get them to take care of the problem, all the while using their own private fleet of aircraft, which is used to transport fruit but also heavily armed, to carry out bombing runs. Now you're getting closer to how it was. Anyways, there's a huge discussion on neocolonialism and how big business has a stranglehold on politics in the third world to this day, but it's a bit too recent to be of too much use to your question.
The short answer is that they gained control by winning the battle of Plassey and Buxar, gaining control of a huge chunk of Eastern India.
But the question is why was the EIC in this position in the first place? The VOC and BEIC are often described as the first modern corporations, but in reality they were something in between. They were a government backed monopoly for the trade of far off lands. They were organizationally corporations, but in their attitudes had hints of the spirit that motivated the Conquistadors and old merchant adventurers.
The BEIC originally managed a series of trading posts along the coast. The Mughal Empire had firm control, and at first found it convenient to do trade with single companies rather than individual merchants. However, as the Mughal Empire declined, the security situation got more complex. The trading posts evolved into fortresses, and began acquiring small bits of land for defensive purposes.
However, the best fight is the fight avoided. Both British and French started manipulating local politics to make sure kings and governors favorable to companies would be appointed. I don't want to get into all the sordid details, but this meddling backfired dramatically when the Nawab (a semi independent governor of the Mughal empire) of Bengal Nawab Siraj-ud-daulah attacked all British fortresses massacring prisoner's and going on a general looting spree. The British, with the help of mercenaries and assorted allies, struck back. The Nawab's armies collapsed, and all of a sudden Britain found itself in control of Bengal.
The BEIC never formally took control of Bengal. Rather, the territory remained nominally Mughal land. Rather, the Mughal emperor (largely a figurehead at this point) gave the British Diwani over Bengal. This means that the East India Company was charged with collecting taxes for the Mughal Empire, and would be allowed to keep a small reasonable amount for itself, and remit the rest to Delhi.
This will shock you, but the EIC decided to invert the formula. The Mughal Emperor would get a small nominal fee, and the East India Company kept most for themselves. The British then raised taxes to stupendous levels, and took everything that would move back to Britain. The EIC never intended to become a large territorial power, but now that it was, it wanted to profit. Ironically, financial management was very poor in the EIC, and while a lot of the employees of the EIC became fantastically wealthy (that's where half of the rich people in Jane Austen novels got their money) the company itself was always on the verge of bankruptcy.