Yesterday, I pointed out that rashi contradicts himself in describing why chazal made a gezeira against bishul akum. Rashi on the mishna says it is one of the decrees meant to prevent intermarriage, whereas rashi on the gemara says that it is a kashrus concern to avoid eating something not kosher.
The gemara 36a had a machlokes why and when chazal made a gezeira on oil (that r. yehuda ne'siah, the grandson of rebbi later removed). Rav says that it was made by Daniel to prevent mingling and intermarriage with goyim, but Shmuel says that it is a kashrus concern since they cook the oil in their non-kosher pots. Tosafos writes that even according to Shmuel the primary gezeira is an intermarriage concern, just that chazal realized that permitting oil will not lead to intermarriage like drinking wine with goyim will (as rashi explains 36b - wine "burns" in a person, meaning that it instigates the yetzer hora). Therefore, chazal needed to support the gezeira on oil by articulating an additional concern of the treif pots. This concept can be further explained based on an idea that R. Moshe writes (igros moshe y.d. 1:43:2) - Chazal don't like to create gezeiros out of thin air. They only make a gezeira if there is some remnant or clear connection to an issur d'roaysa. They need the issur d'oraysa to create the framework for the gezeira, even if the actual concern is something else. Similarly, they didn't want to create a gezeira on oil without a clear association to an issur d'oraysa because the connection between intermarriage and oil is very loose. That is why they had to create a framework of the treif pots in order to forbid oil.
Perhaps rashi is telling us the same thing regarding bishul akum. The motivation to assur it is intermarriage as rashi writes in the mishna, and is clear from the association to oil and bread. But, since it is not clear how eating beans of goyim will lead to intermarriage, the framework of the gezeira had to be as a concern that the goy will feed the jew something that isn't kosher. Tosafos merely rejects the kashrus concern as the primary motivation, but understands that it can be used to create the framework and therefore explains that even when something is cooked in the home of a Jew it will be assur. Although the intermarriage concern doesn't apply, it would be assur since the framework is to assur anytime a goy cooks something from start to finish because they may not be careful about the kashrus of the ingredients.