Two directions at once
Look closely at the middle of a sunflower. The seeds sit in curves that wind one way, and also in a second set of curves winding the other way. Pine cones have spirals like this too, and the scales of a pineapple are often described the same way. Botanists count the curves in each direction.
The two counts are most commonly neighbouring Fibonacci numbers: 1, 1, 2, 3, 5, 8, 13, 21 and so on, where each number is the sum of the two before it. Sunflowers are the most famous example. The pattern does not show up in every species, so a pine cone may not follow it.
No blueprint, just crowding
The plant does not count anything. In one well-known explanation, called Hofmeister's model, each new leaf forms in the least crowded part of the growing tip. The result is a turn of about 137.5 degrees between one new part and the next, called the golden angle. The angle between successive florets in some flowers is the golden angle.
With this model, no two leaves ever follow the same line from the centre to the edge. The Fibonacci spirals are what your eye picks out of that packing.
Not every plant fits
The plant hormone auxin also plays a part. Building up in certain spots at the growing tip, it is described as ultimately controlling where new parts start. Wikipedia flags one detail of this idea, that new parts start where auxin is more concentrated, as disputed.
Some counts look like multiples of Fibonacci numbers, because the spirals are made of whorls. Plants also have other leaf arrangements, such as opposite pairs. Try counting on a real flower and see which you get.

