One supposes that Thanos spent a lot of time bragging to Gamora about it.
Don’t forget, she was his daughter, and until relatively recently in the MCU timeline, was at least somewhat on board with his plans of conquest. In fact, I believe she was the one who said he could destroy half of the universe with a snap of his fingers.
As to how Thanos himself would know this, it seems that the principles of operation of the Infinity Stones are somewhat understood in the MCU, whether by small-scale experiments (how we understand large phenomena in real life) or by the revelation of powerful, ancient entities such as Death or the One Above All (how some people believe we also understand large phenomena in real life). How else could someone make a gauntlet to control them (or possibly more than one)? More than that, the construction of their various containers suggests a certain understanding of how to contain and use their power by various individuals, not just Thanos.
Finally, even if Thanos didn’t understand exactly how the Stones worked, if he had the idea that they would give him “ultimate power,” he might logically have extrapolated that this included destroying half of all life in the universe. And from there, his specific plan (doing it with a snap of his fingers) might be mere personal preference, and of course he would have shared it with his daughter....