There are many yantras in Hinduism for example Sri Yantra. These yantras are usually worshiped and used to attract positive energies or discard negative energies of some kind. Since these yantras would have been designed ages ago, how it was achieved?
The designs of the Yantras all come from the Tantras and Lord Shiva is the creator. That is basically how they have come to being.
In Mahanirvana Tantra's 1st Chapter the Mother Goddess says:
By Thee also have been composed for the good and liberation of men the Tantras, a mass of Agamas and Nigamas, which bestow both enjoyment and liberation, containing Mantras and Yantras and rules as to the sadhana of both Devis and Devas. By Thee, too, have been described many forms of Nyasa, such as those called srishti, sthiti (and sanghara). By Thee, again, have been described the various seated positions (of yoga), such as that of the "tied" and "loosened" lotus, the Pashu, Vira, and Divya classes of men, as also the Devata, who gives success in the use of each of the mantras (50-52).
From these verses it is clear that Lord Shiva created the designs of the various Yantras.
In another chapter of the same Tantra, Lord Shiva gives the instruction of how to draw a particular Yantra:
On his left side the worshipper should draw a hexagon with a point in its centre, around it a circle, and outside the circle a square (185). These figures should be drawn either with vermilion or Rajas (Kula-pushpa), or red sandal paste; the Devata of the support should then be worshipped thereon (186). The Mantra for the worship of the Shakti or Devi of the support is
In the above passage you can see the description of drawing a basic Yantra that is used in worship.
Descriptions of drawing yet another Yantra is given by Lord Shiva in another Chapter of the same text:
The worshipper should then, in the space between himself and the Yantra, draw a triangle with the Maya Vija in its centre, and outside the triangle and in the order here stated a circle, a hexagon, and a square (21). The excellent disciple should then worship in the four corners of the square the Pithas, Purna-shaila, Uddiyana, Jalandhara, and Kama-rupa, with the Mantras formed of their respective names, preceded by Vijas formed by the first letter of their respective names, and followed by Namah (22)
So, the point is how a particular Yantra should be is given in the Tantras already. We have not imagined their forms. Lord Shiva is the creator.
Take for example the most well-known Sri Yantra.
The description of how to draw this particular Yantra is found in many Tantras. In particular, NityAshodashikarna Tantram's Chapter 1, verses 30-45, give the instructions of how to draw this Yantra.
The verses are quite difficult to translate and understand that's why I'm not giving them and besides that there are too many to quote too.
Giving only one and half verse here:
EtadvAhyagatam padmastapatram samAlikhet |
TadvAhyatohapi deveshi shodashAram tathaiva cha || 41
Parivesham bhupuram cha chaturdvAraopashobhitam ||
Outside of that one should draw a eight-petal lotus. And outside that, O Deveshi! one should draw a sixteen-petal lotus in a similar manner. Encircling that, one should draw the three circles and outside of that the squarish enclosure that is endowed with four entrances.
These verses are talking about the outermost designs of the Sri Yantra (if you know how a Sri Yantra looks). In a similar manner, instructions pertaining to how various such Yantras are designed, are found in one Tantras or the other.