Knowing stuff about machinery goes under Knowledge (architecture & engineering). Yes, that means the one skill covers some fairly disparate stuff, but that’s the nature of a game—it has to simplify reality in order to be playable. Many of the skills in the game are multi-purpose, and not all of those purposes are necessarily trained for in the same ways—which means it’s plausible to be good at one and not the other in real life, but in the game that’s not an option. This is a trade-off, a very intentional one, to keep the complexity of the skill system down.
And it wasn’t enough. Characters, even entire parties, have nowhere near enough skill points to actually cover all the skills in the game. Most parties won’t have anyone with any ranks in Knowledge (architecture & engineering). It doesn’t come up enough to be worth it, not when there are so many other, more important skills to cover. Many tables use houserules to combine skills further, even, just to make things more manageable. Pathfinder, a 3.5e spin-off, even made that “official” (though in my opinion they didn’t go far enough).
And the opposite solution—more skill points—isn’t popular because despite the simplification that went into the skills we have, assigning skill points is still much too complicated—another thing Pathfinder simplified further. And we can look beyond 3.5e and its near-clone spin-off here: 4e and 5e eliminated skill points entirely, changing things to just being “proficient” or not in a skill—and drastically shortening the list of skills, beyond even Pathfinder.
Now then, considering that, it makes more sense that Knowledge (architecture & engineering) covers a rather broad swath of knowledge, which is precisely what it does.
Beyond knowing about mechanics, a character might also need to use Craft to actually build a machine. The Craft skill is kind of nebulously defined, so this would be left up to the DM. Certainly, mechanical traps require Craft (trapmaking) to make.
But that still doesn’t actually really address most of your concerns. That’s because for the most part, the world of D&D does not have complicated machines. Maybe Renaissance-era mechanics, but even then we aren’t really talking Da Vinci here. A bridge—and all the associated scaffolding, pulleys, and so on—might well be the most complicated engineering that anyone’s doing in the world.
Which brings us to your iron golems—those aren’t mechanical. Golems are sculptures, brought to life with magic:
An iron golem’s body is sculpted from 5,000 pounds of pure iron, smelted with rare tinctures and admixtures costing at least 10,000 gp. Assembling the body requires a DC 20 Craft (armorsmithing) check or a DC 20 Craft (weaponsmithing) check.
No mechanics involved here, so the crafter doesn’t need to know anything about them.
Instead, the crafter needs magic, specifically:
CL 16th; Craft Construct, cloudkill, geas/quest, limited wish, caster must be at least 16th level; Price 150,000 gp; Cost 80,000 gp + 5,600 XP.
High level, a specific feat, and three mid-to-high-level spells.
And knowing things about iron golems—about all constructs—isn’t Knowledge (architecture & engineering)! It’s Knowledge (arcana). Because you have to know about magic to understand them, because the magic is the real thing making them possible.
And that’s true of basically everything that seems like a complicated mechanism—they are substituting their magic for our superior knowledge of mechanisms.
So Knowledge (architecture & engineering) covers perhaps less than you think it does—because there’s simply less to know about engineering in D&D.