Anakin did not actually build C-3PO. He rebuilt him.
From Wookieepedia:
Originally activated on Affa in 112 BBY, C-3PO had served as a protocol droid to the emissary of the Manakron system. Nearly eighty years later, he was gutted and discarded on the streets of Mos Espa, a city on the Outer Rim world of Tatooine. After being rebuilt by the Human slave Anakin Skywalker, C-3PO served Skywalker and his mother Shmi for over ten years, performing household chores and helping Skywalker earn his freedom by winning a pod race.
So your assumption was correct: C-3PO was built by a government for government use, and his first use was to accompany an ambassador, much like when we first see him in A New Hope.
When Anakin found him, C-3PO was a head and a gutted chassis. However, he still boasted sound wiring, as well as a standard protocol droid verbobrain and communicator module. The communicator module in particular is where the linguistic skills demonstrated by C-3PO originated:
The TranLang III Communicator module was a late generation communication module incorporating millions of galactic languages, installed in 3PO-series protocol droids and LOM-series protocol droids.