Some of the old proverb I have heard that these two foods are come from dead body of cow and thus it is considered like eating meat. Meat is tamasic, onions and garlic are also tamasic and rajasic food. Brahmans possessed the power to bring the dead alive. Once a Brahman performed yajna and sacrificed a cow; to which he would give its life back through his magic chants. But while he was busy in his yajna, one of the members hid some piece of the cow to test his powers. When the Brahman brought the cow back to life he saw some of the belly part missing; on meditating he figured out the reason behind it. The family member realised his mistake and threw the piece far away in the fields to avoid punishment. That enchanted living piece of the cow transformed into edible items; thus the bones changed into garlic and the meat part into onion. Henceforth these vegetables are not considered as vegetarian by all Vaishnava and Brahmin devotees.