It's not merely coincidence that the origins of Mardi Gras and Valentine's Day are so closely tied since both are believed to stem from the same pagan Greek-Roman fertility celebrations connected with Lupercalia.
During the middle ages, the Catholic Church was unable to abolish the ancient traditions of local pagan tribes. Even after conversion, the people continued to celebrate their beliefs and as a compromise, the Church forced adaptation of many ancient feast and festivals. Originally Lupercalia, known today as Mardi Gras, honored the deity, Lupercus (meaning, "wolf"), a pastoral God along with others such as Bacchus, God of wine. Participants in this ancient ritual indulged in voluntary madness symbolized by donning masks and dressing like specters as a way to show they were giving themselves up to Bacchus and Venus. All aspects of pleasure were allowed during the Carnival celebration.
With the embrace of Christianity in Rome came the new interpretation, and carnival was deemed the period of abandon and merriment preceding the penance of Lent. The Lenten period is the 40 days commencing on Ash Wednesday and ending at Easter.