First seen in Marvel Premiere Vol 1 1, the Infinity Stones were originally called ‘Soul Gems’, with the first one (aptly, the Soul Stone) being given to Adam Warlock (more on him later) by the High Evolutionary. It was only when Thanos was searching for a way to woo death (as you do) that he learned about the powers of the ‘Soul Gems’ and so set out to gather them.
Keep in mind that took place before the Infinity Gauntlet story so, yeah, he really was a trend-setter.
An actual origin for the Infinity Stones was given in a story that, frankly, may not even be part of Marvel canon. Since Malibu, a competitor of Marvel in the nineties with their own comic universe known as 'Ultraverse', were going under at the time, Marvel obtained some of their characters for crossover events. The most prolific of these events was called ‘Avengers Ultraverse’.
There’s a whole story to dive into, but the most important point is that this story was the first time the ‘Soul Gems’ were referred to as the ‘Infinity Gems’. That and there was a seventh Infinity Gem, known as the Ego Gem, which hosted the consciousness of the stones.
The story went that in the beginning of the universe there was a being called Nemesis. For reasons beyond “it got super lonely”, Nemesis split itself into seven different entities, with the better known Infinity Gems being the six alternatives to the Ego Gem. It kinda got destroyed though, so that's that.