One of the beauties of baseball is that it is a game of logic, with double-entry bookkeeping, so charging fielder errors for one position as earned while maintaining they are unearned for the other eight positions—and also, maintaining that such runs are earned against pitchers while it is considered not earned by anyone on offense, apparently to satisfy some sort of maximal punishment directive against pitchers—would be illogical and capricious.
There is a specific rule in the book, 9.16(e), which addresses this:
An error by a pitcher is treated exactly the same as an error by any other fielder in computing earned runs.
And that’s logical because once a pitch crosses the plate, a pitcher is no longer pitching. He is fielding, and fielders’ errors can’t count against the pitcher record, because fielding does not occur int he act of pitching. They are neatly separated functions, so by rule, nothing a fielder does, short of the specific function of turning a ball into the out he is presumed to, affects the pitcher record.
This also helps explain the whole deal about why, when there is a strikeout, the putout goes to the catcher, not the pitcher. Once strike three crosses the plate, the batter’s plate appearance ends and it becomes the fielders’ responsibility to complete the out. The closest fielder is the catcher, so he gets most of the putouts on strikeouts, although sometimes the first baseman gets the putout when the ball gets away from the catcher and the batter runs toward first. This is the key reason the batter evens gets to run on strike three: once the at bat is over, the pitch becomes a live ball until the putout is made. This is also why, when the batter manages to reach first after strike three, the pitcher gets credit for the strikeout even though the actual out is not recorded—he completed his end of the bargain, so he gets credit for that. It is the fielder (usually the catcher) that failed to record the out.