Why does timber expand when wet

In which direction do wood boards expand?

Short answer: across the grain.

Wood does move along its length but the amount is negligible and can almost always be ignored.

This has been posted before but it's worth reposting as it shows the differences so clearly:

As you can see radial movement is only half that of tangential (approximately, much greater detail given on this in one of the links below) which is one reason why quarter-sawn wood is more stable than most flat-sawn wood.

Not just expansion
Note that wood expands and contracts, it's not all expansion. There is a natural expansion/contraction cycle that happens to wood through the year as humidity rises and falls.

Wood naturally tries to get its moisture content or MC into equilibrium with the surroundings and it takes up moisture from humid air and expands, loses moisture to dry air and contracts. When you bring wood into the workshop or home and leave it for a while before use as often recommended what you're waiting for is for the wood to reach an equilibrium with the local conditions, a process called acclimation.

Why it's important
So as you can see the more stable the environment the less movement you can expect in any piece of wood, which is why in a house with climate control you can get away with certain things that you wouldn't in another house elsewhere with no aircon and minimal heating. Note: this is so important in the Internet age because many beginner projects that are posted online built from 2x material are very poorly constructed (for example the majority of things on Ana White), and one of the only reasons some makers are getting away with it is because of the stability of the conditions in their homes. Others aren't getting away with it because there are wider swings in temp and humidity inside theirs.

The take-home message here for furniture plans is that everything should make appropriate allowances for movement, regardless of whether it is expected or not. Someone building the project will require it even if the person drawing up the plan does not.

Why pay more for quarter-sawn/radial-sawn wood?
It is radial grain that is across the width of a quarter-sawn board (ditto radial-sawn1) and the much smaller expected movement of such a board is one reason it is so favoured by furniture makers. In addition to the substantially smaller expected movement QS wood can also feature distinctive grain features, e.g. the striking medullary rays (AKA "ray figure") in all species of oak. Beech has a much smaller-scale version of the same thing, not so easily seen at a distance but very attractive up close.

Further reading from previous Q&As:
What is the maximum width for a full cross grain glue up?
What general considerations do I need to take into account for wood movement?
Thick tabletop movement

1 Radially-sawn wood is also sometimes referred to rift-sawn although it doesn't mean quite the same thing. Strictly speaking radial sawing refers exclusively to how the log was converted into boards, literally in a radial fashion. While rift-sawn can refer to grain orientation in a board only, which is also true of quarter-sawn wood, regardless of the method used to saw the boards from the log.