Things on paper are written in pencil, but on or with a typewriter. I'm sure there are lots of other similar examples. Oy. People who have to learn English as adults must find it nightmarish, in a Kafkaesque way.
So is English just unruly or is something else afoot.? The latter I think. The trouble arises because prepositions are common in English. We hear examples of their use continually. This means that our knowledge of them is informal. We develop rules governing their use, but lacking careful thought we draw the wrong conclusions.
Eugene's example actually hinges upon ambiguous word usage, not on the prepositions. Consider: pencil is both a tool and a pigment (graphite). When people say something is written in pencil they refer to the composition of the substance marking the page. Just as they might say written in type. But to say written with a typewriter is to designate the tool used. Just as we might say written with a pencil. Also written is used two different ways.
So this example is apples to oranges.