How come roasting thing makes them carcinogen but roasting coffee is fine? ?
Some chemicals are made or worsened by high heat and others are made better or neutralised at lower temperatures
https://www.healthline.com/nutrition/acrylamide-in-coffee
The toxin in potatoes is solanine is supposedly not destroyed by boiling but is by high temperature frying. Which is probably why potatoes are peeled and fried commonly.
https://www.eatthis.com/vegetables-healthier-cooked/
This site lists with some links to extra info how some vegetables nutrients vary by cooking and method.
So it’s clear that the wide variety of chemicals in foods needs a wide variety of preparation methods to get the best from them. The general concept of why roasting is not best is because of mailard reaction but it’s again a matter of degree and detail. A bit of browning like in many foods is likely not an issue. Some people believe that the toxic level might be related to when foods are perceived as “burnt”. Toast being a great example.