In a fantasy world with late 18th-century technology, how do their armies use golems?
The fantasy world I envision is a pretty standard D&D-style fantasy world, similar to Toril, but with a higher level of technology, equivalent to Earth in the late 18th century—that is, they have black powder muskets,muzzle loading cannons, and line infantry.
In their wars, golems were important combat units—they were typically relatively inexpensive stone golems, clay golems, and sand golems. they were immune to most magic and virtually invincible to the infantry muskets, making them extremely useful on the battlefield.
the most common use was to position them in front of line infantry to withstand enemy fire. they could also serve as mobile artillery mounts, allowing for faster artillery movement, or for deployment in complex terrain. clearly, they would develop specialized shield wall golems and artillery mount golems.
however, they remain extremely expensive; perhaps in most countries, a company of infantry could only possess one golem, or they would be pooled together for deploy—which means they are more vulnerable to enemy artillery fire.
after careful consideration, I concluded that cost was the biggest problem. They had to reduce the cost of golems to a very low level—for example, to the cost of only a few cannons. otherwise, golems could not become standardized units in large-scale warfare and would only remain as private toys for a few important figures.