I know you can't influence the specialization of your projects, but what about their eventual upgrades? Or even what kind of project the village founds in the very beginning?
What makes one granary turn into plantation, while the other turns into a mill? Why does one desert build a shrine, while the other does a market?

From memory I don't think that you can encourage certain projects, at least I never managed to. However each archetype has a prefrence to certain projects, Forest Villages start food orientated projects, Desert Wealth and Swamp Tech. So that may be the main cause of the early projects that you have been seeing.

That's a good guideline, but not necessarily a rule. I've seen Swamp Villages start the fishing projects (food/wealth) as well as granary projects (food). I've also seen Desert Villages start wealth/tech that gives like +5 wealth +10 tech per mineral. Desert Villages obviously can't be close enough to the ocean for the ocean projects. But I also see Desert Villages start Shrines (food/wealth).

And the Wiki actually says that things like the Granary can pop up in the Desert (food), though I've never seen it myself. Only the School (food/tech), Fishing Docks (food/wealth), and Mountain Lodge (everything + natura) are unable to pop up on desert tiles, though the latter can be quite common for desert villages due to Mountains.

But... you can force any swamp/forest village into Fishing Docks/Harbor then Lighthouse/Island Town by simple not giving them any land (settle the village, then use ocean giant to put ocean right up to village edges).

Other than forcing via ocean though, there's not a whole lot you can do. It's random, but weighted toward certain preferred projects. Forests prefer food-based projects, swamps tech-based, and desert wealth-based. The resources available to the village don't seem to have any effect on this. Forest villages are going to most likely start Granary/Shrine/School projects no matter what resource you pop down for them. Desert villages are going to most likely start with Tradepost/Shrine/Toolshop no matter what resource you pop down for them. And swamp villages are going to most likely start with Druid/School/Toolship no matter what resource you pop down for them.

The 1st and the 3rd will always be random, awhile the 2nd and 4th are always related to the previous one.

For Instance, you have a Forest Town, without any mountain. The first project can a lot of things, but with preference for "food related projects". You can end up with a School, with a Granary, Fishing Docks, Shrine, etc.

But the second project in this town will always be related to the first!

For instance, if you got a "School" as first project, the second one will necessary be "Barracks" or "University".

If the first was the Granary, the second will always be "Mill" or "Plantation".

The thrid project has no string attached, so it, again, can be any project from the biome. But the 4th is also related with the third, and usually, there is only one kind of 4th one (before the Patch, there was only one, but now with Town Canal this isn't true anymore).

For instance; Observatory will always upgrate to Laboratory; Blast Furnace will become a Factory; Circus will become an Opera House, Bank a Multinational, and so on.

So although there is a random component, you will have a very limited options of projects in the 2nd and 4th level an can plan ahead!