Question: How do humanity and its social structures evolve in history?
All three play a role, but decisive are unintended consequences of intentional actions. Ultimately, the structures in human societies evolve according to the same principles as those in other animal populations: the basic principles of evolution: reproduction, variation, selection. Only with the difference that humans (sometimes) act intentionally, i.e. certain variants are deliberately and consciously introduced into the process. However, whether these variants then are positively or negatively selected depends on factors (so-called "selection parameters" ) that humans cannot control. To put it in one sentence: "History is the result of human actions, but not of human design".
Through the evolutionary process our brains developed the ability and capacity to think creatively, critically, logically, rationally and intellectually to survive but over the course of history we began to think about ourselves, others, the physical universe and the role we have to play.
Humanity and its social structures has evolved through ideas most importantly the invention of language ie letters, words, phrases, concepts and ideas
The implementation of the invention of ideas, concepts, letters and words due to the invention of language
Philosophy moves history. As an example, when the Western world followed Christianity as its philosophy, we had the dark ages. When Aristotle's philosophy of reason was again discovered and added to the Church's dogma, through Thomas Aquinas, we started coming out of the dark ages and into the Renaissance. When the ideas of reason crept through society, we entered the Enlightenment, and ideas of freedom, through philosophers such as John Locke. The Enlightenment, with its ideas of reason and freedom, led to advancements in science, political structure and capitalism. The U.S. was the first nation in history that was formed on ideas -- those enlightenment ideas. The story continues. The ideas of German philosophers, beginning with Kant, started infiltrating Western society, moving us away from reason. The ideas of Karl Marx and Engels led to Socialism, Communism, and Fascism, which moved society away from freedom. Modern philosophers are responsible for most of the ideas that are moving in society today. Ideas such as egalitarianism, multiculturalism, income inequality, and the like. In the U.S. we are becoming more socialistic as a result of those ideas.
Maybe the most basic human social structures arose from primitive behavior patterns. Those behavior patterns which evolved over millions of years are the most deep-seated ones because there has been time for less successful alternative behavior patterns to be weeded out. Examples might be the tendency to engage in combat, evident even in our chimpanzee cousins, which has led to the social structures called armies. Innate religious behavior led to churches, trading behavior led to factories and businesses, gender roles led to families.
As you say, we humans are consciously aware and have the ability to shape the direction of evolution. But it might be hard or impossible to change our most basic behavior patterns and their associated social structures because their origins are in the distant past and they form an integral part of who we are as human bodies.
What about as unintended consequences of the plans and actions of people? As people, we may set out to define the world around us, but sometimes the world doesn't approve of our plans and reacts as we couldn't or didn't predict, as a way of asserting its will and saying, "Nice try, fucknut!"