How do aircraft keep fuel from freezing while in flight?
Much like water, exposing fuel to below freezing temperatures does not instantly make it freeze.  It takes some amount of time, and as long as the fuel is not exposed to below freezing temperatures long enough to make it freeze, it won't be a problem.

How much time?  That depends on a number of factors like:


Type of fuel


Jet A (common in the US) has a freezing point of -40 C
Jet A1 (common outside the US) has a freezing point of -47 C
Jet B (common for some military aircraft and very cold airports) has a freezing point of -60 C

Initial fuel temperature


If you fuel in the middle east during the middle of summer, the fuel will be a lot warmer than when you fuel in Siberia in the middle of winter.  Warmer fuel will take longer to freeze.

Outside air temperature


Much like trying to freeze water to form an ice cube, the colder the air around it, the faster that it will freeze.

Aircraft speed


The faster that the airplane goes, the more friction there is as the air flows over the wing.  This heats up the air close to the wing and makes it take longer for the fuel to freeze (see previous point).  The temperature at the wing is known as TAT:
For example, at an actual temperature of -56.5 C (SAT) and Mach 0.72 the TAT is -34 C, but at Mach 0.80 the TAT is -29 C.
For more information about SAT -vs- TAT, see my answer about Air Data Computers.

Quantity of fuel 


Much like a small pond will freeze before a large lake, in order to get fuel to freeze you need to lower the temperature of all of it.  
The more that there is, the longer it will take.

Aircraft design


Some aircraft run hydraulic lines close to the fuel so that the heat will help slow down the freezing.
Some aircraft constantly pump fuel to keep it moving and mixing if it tends to freeze in one part of the tank before the rest
Some aircraft use fuel to cool the engine oil using a heat exchanger, and return the warmed fuel to the tanks
Many other design factors



In general, fuel will not freeze in the typical amount of time that an aircraft is aloft.  If particular routes pose a problem, there are several options that the operator and pilot have:


Use a fuel with a lower freezing point
Fly at a lower altitude where it is not as cold
Choose a route with warmer temperatures
Increase the speed of the airplane
Carry extra fuel
Transfer fuel in a way to keep fuel warmer.  Typically this is done by transferring fuel from the relatively warm fuselage tanks to the wing tanks which are exposed to more of the cold air.