Our idea of a "modern functioning state" relies on concepts of sovereignty that didn't begin to gain wide purchase in Europe before the Peace of Westphalia—at least 150 years after European colonial efforts had begun.

The colonial project in Europe was concomitant with the development of western concepts of national sovereignty and the emergence of the modern bureaucratic state. In fact, many features of modern governments emerged specifically as mechanisms to implement colonial policies, and the material resources that were used to build up the institutions of many Western states were largely extracted from the colonies. In light of that, it seems strange for you to critique colonized polities for being "pre-modern" prior to colonization when European colonizers were themselves largely pre-modern before colonization efforts began, and themselves modernized—both in material terms, and in terms of the sophistication of their institutions—at the expense of their colonies.

That "the purpose of colonization was to establish such a thing as a functioning state" is only true in a technical sense. The ultimate purpose of colonization was extraction, and in order to implement extractive policies, modern bureaucratic institutions needed to be established, both at home and in the colonies. Many colonizers, when they departed, may have left their colonies with governing institutions that resembled the institutions that the colonizers had created at home—but only in the way that franchisee businesses resemble the businesses of their franchisors. Colonial governments depended entirely on their metropole for essential aspects of governance, and could not serve any meaningful function without tight integration with their home country governments. This even remains true of some post-colonial governments today.

Even if colonial institutions had been established "for the sake of enabling trade and commerce" those institutions would have been insufficient to govern independent states.
But the terms "trade and commerce" presume the existence of peer counter-parties who are able to negotiate at an arms length to arrive at arrangements that benefit all parties. Colonial institutions were not at all established for that purpose—they were established for the purpose of resource extraction at the expense of a subjugated population. A governmental orientation towards trade and commerce could have given former colonies at least a starting point on the road towards economic development, but in actuality the governing institutions that former colonies inherited were entirely oriented towards giving the industries of their former colonizers uninterrupted and privileged access to cheap labor and cheap resources.

European colonial governments employed many different tactics to deliberately destabilize colonized polities—destroying, subjugating or co-opting pre-colonial (and post-colonial!) governing institutions; intentionally pitting rival ethnic, class and religious groups against each other; creating borders within the contiguous territory of cohesive ethnic & linguistic groups, while forcing groups with disparate languages and cultures to share the same government [1]; denying indigenous people equal (or, in many cases, any) opportunities for social, economic, and political advancement; suppressing (and often stamping out) indigenous languages, cultures and religions; suppressing independent local industries that might compete with industries in the metropole; and suppressing independent political thought and local political institutions—all of which had the effect of preventing the development of institutions within the colonies that could keep pace with the development of modern institutions in Europe.

The underlying objective of the colonial project itself, however, was perhaps the most destabilizing. The system as a whole was designed and implemented to maximize the flow of economic value out of the colonies and into the metropole. Every institution was optimized for that purpose, and any element of local politics or culture that did not contribute in some way to that effort was discouraged, suppressed, or eliminated, through the (often violent) application of state power.

GP is entirely correct to write that "colonization is majorly impactful and leads to disarray for decades, if not centuries," and that "countries need time to stabilize, after being systematically dismantled and robbed by colonizers."