The Trinity is not explicitly stated in the Scripture. It is something the Church constructed as an intellectual effort, from the revealed truths.
The Church fathers were influenced in their trinitarianism by the neo-Platonists (including Plotinus, Proclus and the Pseudo-Dionysius). These guys characterized the fundamental triplicity at the root of things as follows:
mone (remaining, abiding); proodos (going forth); epistrophe (returning, turning back).
mone became "God, the Father" (Who abides in Himself); proodos became "Jesus, the Son of God" (Who goes forth into the world); and epistrophe became "The Holy Spirit" (Who mediates the return to the Father).
Of course, the neo-Platonists weren't called neo-Platonists for nothing; they owed most of the deepest aspects of their thinking to (their interpretations of) Plato's writings, and this includes their trinitarianism. But that's a matter for another post at another time.
The overall position of the Church is that even cultures ignorant of Christ have a correct religious instinct written in their heart. We should not be surprised if we find elements of revealed wisdom discovered independently by cultures otherwise unenlightened.