The trinity concept comes from Hinduism. Brahma, Vishnu, Shiva. It's a very old doctrine. It just does not fit that well in Christianity because the Catholic Church has done some theological syncretism, which blends together some aspects of other religions with it.
But if you want to know how the trinity is explained in Hinduism (not for the faint of heart)
"Brahma, Vishnu and Shiva, the triple gods of Hinduism, are different in a limited sense only. They are considered manifestations of the same Supreme Isvara, who is also known as the Saguna Brahman or the awakened or dynamic Brahman. Isvara Himself is considered by the monists as a reflection of Supreme Brahman in (the triple gunas of) Nature. Since ordinary human minds cannot comprehend the oneness of the universe, it becomes difficult for us to understand this concept clearly. To summarize the idea briefly let us take the analogy of a person performing different tasks. Just as a person becomes different persons while performing different roles or duties in the mental plane though not in the physical plane, God who exists in innumerable planes simultaneously appears as the Trinity in three different roles. The difference if any is in appearances which is part of the grand illusion that He weaves all around us.
Where do they exist?
The triple deities (Trimurthis) do exist in space and time, although it is difficult to explain the nature of their existence, as well as their true potentialities since they belong to the very highest realms of creation. In the human beings they exist beyond the mind as potentialities of the divinities of the super-mind or the divine mind, who are envisioned only by a handful of adept yogis in deep meditation. Seemingly there is nothing physical about them although in their ignorance people tend to consider them human beings with flesh and blood. From the experiences of adept yogis and self-realized souls, we understand that although the triple deities remain in their ethereal aspect as pure energies and consciousness with dimensions beyond our imagination and comprehension, they can assume physical form when they deem fit, appear anywhere in the universe at will, and manifest themselves in whatever way they choose. They are God's most pleasing and benevolent aspects in the manifested creation, personifying His dynamic functions. They represent His will in cognizable forms with which the human mind can interact and relate well.
Are these gods different from each other?
To the question whether these gods are different, the answer is both yes and no. They are different because, from human point of view they perform different tasks, have qualities and energies that differ widely from one another and also control different worlds that seem to set widely apart. But as we have mentioned earlier, at the highest level they are the three aspects of the one and the same supreme Reality. Together they are like a mighty flow of energy branching out into three different streams at the point of contact with human awareness.
It is difficult for us to understand them, because we can understand reality in terms of comparisons, with reference to one another, not by the thing itself and because we can concentrate our attention upon only one thing at any given point of time, while our minds cannot hold two thoughts at a time. Imagine an intelligence that can understand infinity without the need for any comparisons and hold an infinite number of things simultaneously in its unlimited field of consciousness without any reference to each other, without the need to know, without any effort to know, and knowing them all at a time! This is the consciousness of these divine planes."
The highest gods of Hinduism Brahma, Vishnu and Shiva are also called the Trinity or the Trimurthis
hinduwebsite.com