Why do onions taste sweet when cooked?
The sweetness of onion is caused by the sugar of onion itself. The reason why we can't feel its sweetness when we eat it raw is because the strong irritating gas contained in onion masks its sweetness, and cooking destroys the gas released by onion, so the sweetness is only shown after cooking.