If humans are just a bunch of extremely complicated gears working together, how can we have self-awareness?

Short answer: Because some bunches of extremely complicated gears are capable of self-awareness.

Longer answer: We need to ask whether the reductive term "just" in your question makes the question tendentious (i.e., biased). To the question "If humans are just like the non-self-aware bunches of gears that we understand best -- such as the bunch of gears in a clock -- then how can they be self-aware?" the answer is clearly "They can't." But the latter question isn't interesting, so presumably it's not the question you intended to ask. To put it another way, humans can be bunches of gears (using "gears" only metaphorically) without being merely bunches of gears. It could well be that when a bunch of gears gets complicated enough, it becomes capable of self-awareness. Exactly how that happens is a question for neuroscience rather than for philosophy.

Read another response by Stephen Maitzen
Read another response about Consciousness