Does Exodus 34:12-17 suggest that erecting sacred structures to idols and eating their meals created a kind of political alliance?
While that possibility could occur, the counsel that Jehovah God is giving the Israelites is just the opposite. The idea is that political alliances could lead to the worship of foreign gods.
Scenario 1
An Israelite male would marry a foreign woman for political advantage. This would benefit both parties in that they agree not to war with each other. The problem arises when the foreign wife then says "We need to go to the festival of [insert foreign god]." As her head, the Israelite husband would say no. But how long would this last? Would she not continue to ask, beg, or even nag him to the point that he concedes? How many times would this happen until the Israelite husband stops his worship of Jehovah God?
Along with this, what would the foreign wife say when the Israelite husband tells her that there times a year they have to go to the tabernacle/temple? She would probably tell him that that applies to him and not her. (Exodus 34:23)
Scenario 2
An Israelite female marries a foreign male. She is well aware of how men are given privileges within the Mosaic Law and that the husband is her "lord". (Genesis 18:12) This could make her think that she must obey her foreign husband when he tells her that they must attend the festival of [insert foreign god].
In both scenarios, they would be at odds as to their way of life, faith, their children, growing crops, etc. The Israelite husband/wife would be introduced into practices that would oppose what Jehovah God had commanded against but would acquiesce to these practices as Paul puts it to "gain the approval" of their spouse. (1 Corinthians 7:33, 34)
In the book of Judges, we see time and time again how the nation of Israel would deviate from their worship of Jehovah and prostitute themselves with foreign gods. (Judges 2:17) The Israelites had forgotten the incident on the plains of Moab when many lost their lives for turning away from Almighty God. (Numbers 25:1-9)
The greatest example of violating the commandment in Exodus 34 is that of King Solomon.
1 Now King Solomon loved many foreign women. Besides Pharaoh’s daughter, he married women from Moab, Ammon, Edom, Sidon, and from among the Hittites. 2 The LORD had clearly instructed the people of Israel, “You must not marry them, because they will turn your hearts to their gods.” Yet Solomon insisted on loving them anyway. 3 He had 700 wives of royal birth and 300 concubines. And in fact, they did turn his heart away from the LORD.
4 In Solomon’s old age, they turned his heart to worship other gods instead of being completely faithful to the LORD his God, as his father, David, had been.–1 Kings 11:1-4 NLT
Furthermore, making marriage alliances with foreign nations would mean that the Israelites were no longer leaning on Jehovah God for their prosperity. Jehovah delineated all the blessings the Israelites would receive if they were to obey his commandments. (Deuteronomy 28:1-14) The Israelites were, in effect, telling Jehovah God, "We don't need you."
[Unless otherwise noted, all scripture quotations from the New World Translation of the Holy Scriptures (Study Edition)]