Tides are primarily caused by the pull of the sun and the moon on the water. The combined effect pulls the oceans into a sort of double bulge around the earth. Since the earth is rotating once a day (by definition) each point passes under the deep part of the bulge twice a day and the shallow part of the bulge.
The moon, being closer, provides a much more pronounced effect. This is why the high tide isn't the same time every day (since the moon takes a bit over 29 days to circle the earth). Higher tides occur when the moon/sun/earth are in a line with each other (neap tides) and lowest when they are 90 degrees (spring tides).
Of course, due to the fact that the moon isn't synchronized with the earth, the tides are actually slightly more than 12 hours apart. So yes, there aren't quite 2 highs and 2 lows a day, but it's close enough.
There are local effects on the coastlines as the water can't just freely flow from one place to another as the earth rotates so in some places you get very high diurnal tides (Bay of Fundy) or even places that don't have diurnal (twice a day) tides.