As we answered earlier in What is Gotra?.
The Gotra is a lineage system of a person with his most ancient ancestor in an unbroken male lineage.
The practice of forbidding marriage between members of the same gotra was intended to keep the gotra free from inherited blemishes and also to broaden the influence of a particular gotra by wider alliances with other powerful lineages. The people from same Gotra are called as "Sagotra" (सगोत्र). A woman leaves her born-Gotra and enters husband's Gotra after marrying to him. That is the main reason, it follows Man's (Father's) Gotra to distinctively define the rules.
People are prohibited to mate in same lineage due to the fear of Genetic Similarities that may result into offspring risks. Irrespective of Gotra system, progeny of same lineage couple is widely discouraged and has seen genetic disorders.
According to Hinduism, a marriage must be consummated with procreation of succesor progeny. There are rules and traditions for within marriage procreation apart from traditional ways, like Noyoga (offcourse this is different from adulterous or extramarital relations). Those practices are considered uncoventional, atypical and unwonted by today's society. Gotra system provides a Framework to avoid Genetic defects. In void of any framework like that, the problems cannot be avoided or even detected, cannot even be traced back to Sibling-like parenting in earlier generations etiher.
"Marriages between Sagotra are prohibited by ancient texts on Hinduism" is not completely correct. The man and women are supposed to tell their Gotra for last Seven (7) generations, and if no conflict between those, the marriage or progeny was allowed. Some of the ignorants mention like here, Sagotra marriages are prohibited forever, which is completely untrue. The risk of genetic disorders caused by sibling-like parents sharing DNA is less than 0.0001% (that is possibility, not definitive) over more than 7 generations. Hinduism allows marriages between "Sagotra" after 7 generations, but application of this corrollary, and such possibility becomes very rare just because 7 generations would be 210 human years (considering 30 years a generation).
At the conclusion, per Indian Law, Sagotra marriages are legal. We are currently at rare and critical times when "Old Orthodox Generations" and "New More Liberal Generations" are at conflict over this. Law allows everyone to live their life freely. The Law provides support and protection to individuals those who do not believe in Gotra and are unwilling to follow it. Secular Law of India certainly does not stop anyone who wish to follow the "Gotra Doctrine". So it is upto the individuals to follow the Hindu Gotra rules by being more traditional or ignore them by being a liberal.
Legality empowers the freedom of choice, also with freedom comes power and with power comes responsibility. If we forget any of these, it may lead into disasterous progeny which is undesirable by liberals or orthodox both. Orthodox thinking provides a framework to avoid the genetic problems, where liberal does not address that. For liberals, with lack of a framework to avoid the problems, the responsibility plays a major role with choice and must be executed carefully.
Some references :
धर्मसिंधु/ Dharmasindhu by Kashinathshastri Upadhyay - Book for summary of Hindu Rules - "तृतीय परिच्छेद : पूर्वार्ध २".
धर्मसिंधु / Dharmasindhu b yKashinathshastri Upadhyay - Book for summary of Hindu Rules - "तृतीय परिच्छेद : पूर्वार्ध ३".
Sanskrit Version of धर्मसिंधु / Dharmasindhu.
निर्णयसिंधु / Nirnaysindhu - Book of Summary of Hindu Decisions by Rules and Exceptions to Rules