I know if a runner crosses a plate on an error made by a defending player, the run doesn't count as earned to the pitcher but if the runner scores because of an error made by the pitcher, shouldn't the run be counted as earned because it's the pitchers fault that the runner scored?
No he doesn't.
Pitcher errors are counted alongside other defensive errors and are treated the same for the purpose of determining ERA. If a run scores as the result of an error, it doesn't matter who committed it, that run is not counted for ERA.
This is explicitly covered by the rules, as well. MLB's Official Baseball Rules (OBR) 2015 edition Rule 9.16(e) is very specific about that:
An error by a pitcher is treated exactly the same as an error by any other fielder in computing earned runs.