Modern democracy is normally conducted by elected representatives, chosen in competitive elections (where incumbents have a chance to lose). From the standpoint of the voters, elections are the (thin) connecting line between what voters want or will accept and the policies chosen by their government. But this is so only to the extent that elected officials can actually lose elections and are not able to so exploit the advantages of office as to insulate themselves from voters. From the standpoint of elected officials, elections are a matter of political life and death. To survive and have their policies persist, they have to win or at least win pretty often. Therefore, policies are chosen, in part, because officials think will help them prevail next time. One cannot of course expect governments to be very good at figuring which policies will have this effect. The connection between policies and the outcomes voters care about is complex and obscured by risk and uncertainty and, in many cases, very weak. Moreover, modern democracies are internally complex with separated powers and internal checks, making coordination on policy difficult and sometimes impossible to achieve (despite the invention of the political party). So governments get things wrong fairly often either because they cannot figure out what to do, or, cannot do actually manage to do what they know they should do. And, as a result, as long as elections really are somewhat competitive, sometimes governments lose elections.
For all its flaws, the traditional democratic conception is usually defended nowadays in the following way: the policies that work electorally are those that tend to produce good outcomes for voters. And elected officials are thought to be at least somewhat competent at finding such policies and so can be (rationally) expected to pursue them in between elections. So, even if there is a bit of noise (i.e., failed policies, electoral defeats, etc.), and even if the election motive distorts policies a bit toward short run electoral concerns, and even if electoral worries can make it hard for representatives to coordinate their actions, on balance democracy usually tends to produce outcomes acceptable to the electorate.