Your question is not totally clearly phrased, but basically you seem to be talking about three things:
- frying onions
- frying tomatoes
- toasting spices
Separately spices can either be dry roasted or oil roasted.
The interesting thing about oil is that a lot of compounds from spices are considered fat soluble. There is a longer discussion here: https://www.seriouseats.com/2014/07/indian-spices-101-benefits-frying-spices.html
but essentially frying spices in oil dissolves those compounds in the oil, and this oil will then form part of the dish. If you dry roasted then obviously this would not happen
There is a 455 page treatise on the Chemistry of spices here https://catbull.com/alamut/Bibliothek/Chemistry_of_Spices.pdf from the Indian Institute of Spices Research in Kerala.
For example nearly all of the volatiles in coriander are monoterpenes which are very poorly soluble in water. This is why perfume is generally made from an alcohol base. Here fat (oil) is the base.
If you dry toasted it's likely that the release of moisture from the spices would affect the flavour profile differently.
For ginger, specifically:
"Ginger owes its characteristic organoleptic properties to two classes of constituents: the odour and the flavour of ginger are determined by the constituents of its steam- volatile oil, while the pungency is determined by non-steam-volatile components, known as the gingerols. The steam-volatile oil comprises mainly of sesquiterpene hydrocarbons, monoterpene hydrocarbons and oxygenated monoterpenes"
Gingerols are flavour compounds themselves, and are converted into zingerone, shogaols and some remain as gingerols. Gingerols are the spiciest, then shogaols, and zingerone is considered sweet.
This study found:
"The ratio of 6-gingerol to 6-shogaol concentration in raw ginger was 98:2. After boiling and steaming for 60 minutes, the concentration of 6-shogaol increased by more than 3 times; this difference was statistically significant (p<0.01). However, it was also confirmed that a sufficiently high amount of the 6-gingerol in ginger was retained after boiling (93:7), steaming (92:8) and stir-frying (97:3)"
It would seem that frying ginger first would result in a different flavour profile to if it was cooked in a curry base which would not exceed 100C (boiling temperature of water).
As far as tomatoes go, they contain a lot of water. This means that if you add them first, then you are no longer getting the high heat oil based reactions with the spices. So probably if you want to fry spices it's best to do them separately.
Frying tomatoes and onions is mostly about the Maillard reaction:
Frying tomatoes releases more of these flavours than boiling would.
For onions, there is a study here:
comparing three techniques - sué ('sweating'), sautéeing, and pan frying.
*Sué onion preparation: 30 g of sunflower oil were added to a saucepan heated to 100 °C and 1 kg of onions was then added. The onions were regularly stirred for 25 min. Cooking was stopped when the onions were translucent.
Sautéed onion preparation: 30 g of sunflower oil was heated to 155 °C in a pan. Then, 1 kg of onions was added and was evenly sautéed for 10 min. Cooking was stopped when onions had a homogeneous caramelized appearance.
Pan-fried onion preparation: 30 g of sunflower oil was heated to 130 °C in a pan. Then, 500 g of onions were added and were evenly sautéed for 18 min. Cooking was stopped when onions had a shiny appearance and some of them were burnt.*
There were very significant differences with the pan-fried onions:
Much higher levels of:
- 2-Methylpropanal (spicy) was found compared to the saute (present), and the sweated (absent)
- Various sulphurous compounds - much higher in the saute
- 3-Methylbutanal (malty/animal feet) - absent from the sweated, present in the other
- 2,3-Pentanedione (buttery) - only in the saute
- Caramel flavours - higher in the saute and the pan fried
This is only for different methods of frying. It seems likely that the further process of cooking the curry would tend to break down the spicy and sulphur flavours that are left behind after a saute, so the difference would be less than this presents, but it should still be present - a long slow cook of the onions will make them taste seeetest. On the other hand flavours introduced by first browning the onion would be more durable
So I would fry spices first in oil, keep the oil as a minimum. Whether you want toasted onion flavours in your butter chicken seems like it would be a matter of taste, but cooking them long and slow will give them sweetest taste. For tomatoes frying will add flavour compared to boiling, though baking adds even more flavour.