Was mentioned in passing recently, did a bit of research and was really confused. What were the motivations that caused such willy-nilly side-switching throughout the war(s)?
So the War of the League of Cambrai was part of the overall Italian Wars, basically a series of wars, usually arising from some sort of domestic dispute, but quickly became a way for the great powers to try and gain influence and territory in Italy. Anyways, one of the most powerful states in Italy was the Republic of Venice and south of it was the Papacy, one of the other major players in Italy. Anyways, the Pope at the time, Pope Julius II wanted to build the Papacy into a powerful state and to curb the influence and power of Venice. Relations were further strained when nobles who's lands had fallen under the control of the Papacy under the Borgia dynasty, fled to Venice, the nobles promised to submit to Venice if Venice would help them get their lands back. Venice agreed and seized the lands in the area known as the "Romanga". It was under these circumstances that Pope Julius decided to build a coalition to help beat the Venetians. He sent out emissaries to all the powerful states that had a stake in Italy, the French, Spanish, and the Holy Roman Empire. He basically promised them a share in the dismemberment of the Venetian Empire if they would join the coalition. On December 10th, 1508 The Holy Roman Emperor and the French joined the coalition, and a few months later the Spanish joined. The coalition appeared ready to destroy Venice. The first battle occured between the Venetians and the French in May of 1509, where Venice was beaten quite easily at a place called Agnadello. But after that setback things turned towards Venice's favour. Cities began declaring for Venice and the Venetians beat back a German siege of the city of Padua. And Venetian generals began winning victories and destroying Papal and Imperial armies. But the defeat by the French was grave enough to cause the Venetians to sue for peace, the Venetians lacked the funds and the manpower to continue, so peace was probably the best bet for Venice despite the recent trend of victories. There were debates in the Venetian senate, but ultimately a peace was signed and Venice lost a good chunk of its territory to France and the Papacy, the Holy Roman Empire however gained nothing, and the French were beginning to overstay their welcome in Italy. This where the confusing web of alliances begin to breakdown.
The first phase of the war was over in 1510, and now that Pope Julius had weakened Venice it was time to weaken France. France hadn't wanted peace as they wanted to seize more territory. So Pope Julius now needs an ally to counter the French and the Germans who are now semi allied. So who does he turn to? Why Venice of course, and Venice wanting to regain territory forgets the previous war and agrees to an alliance. Oh the joys of Renaissance Italian politics. While the Pope had made peace with Venice, the French and Germans had not, and a French/German army was rampaging through Italian territory, taking cities and looting the countryside. The Venetian-Papal alliance (second phase 1510-1511) went on the offensive quickly and the Venetians regained a lot of towns taken by the French in the previous years. The Pope began excommunicating the French King's allies in Italy and began building an alliance of states against the French. The two sides battled back and forth, with the French and their few Italian allies fighting with the combined forces of the Pope and Venice. While the Venetians were able gain back much of their territory, no side could make any real gains and both sides scored victories. The French did capture the city of Bologna and began to build more momentum and scored some victories over the Papal armies, but it wasn't enough to force peace. So Pope Julius began to contemplate a new holy league to fight the French. Comprised of Spain, England, Venice, and the Holy Roman Empire. And this was actually very easy to build, everyone had grown tired of the French and no longer Venice as a threat. Spain and England gleefully joined, as did Venice who was still fighting the French. The Germans as usual kinda of dithered and gave half promises, but even without them the league was growing powerful enough to expel the French.
The third phase arguably started when the Pope declared his holy league on October 4th, 1511. However, the league would get off to a bad start because the French had a daring new commander named Gastion De Foix, the nephew of the King. He destroyed a Spanish/Papal army trying to capture Bologna, then quickly marched back to French territory, destroyed a Venetian army sent to intercept him, and them put a down a pro-Venetian revolt in French territory. The city of Bresica was sacked and the other cities quickly fell in line. The French and Spanish/Imperial forces clashed again in the battle of Ravenna. It was a bloody affair, where the French lost nearly 4,000 infantry, and numerous commanders had died, including the young French commander De Foix. While the French technically "won" their army was leaderless and in hostile territory. And there was rumours that the English were going to hold up their end of the bargain and invade France any moment. The French army withdrew, and new mercenaries hired by the Pope combined with the Venetian armies to force the French out of Milan, and the traditional rulers of Milan, the S'Frozas took over the city of Milan. The Papacy and Venice recaptured their territory and now the victors met at Mantua to divide the spoils.
Every member of the league got something, except Venice, who the Pope conspired to keep weak. Venice was angered that it had lost so many men, and had contributed so many resources to the defeat of France only to get nothing, so what did they do? Naturally they switched sides and allied with the French. The same French who had been plundering and attacking Venice for a few years, the same French who had been hell bent on destroying Venice just five years prior. Pope Julius died in early 1513, and his successor Leo X was not nearly as skilled diplomatically or militarily. The French and Venetians signed the Treaty of Blois which was an alliance. The French confident in their power, marched into Milan, as the Venetians marched from the East. The ruler of Milan was unpopular and the conquest, for the most part was easy, until the ruler of Milan gathered all his forces and launched a last ditch assault on the French. The assault worked as the French were caught of guard and the French army retreated leaving Venice on their own, facing the Holy League that had not yet been disbanded. The Venetians were able to survive mainly because the city of Venice itself was so hard to siege. The Venetians were on the defensive, and probably would have lost, had the French king not died. The previous French King had been old and was not so interested in the affairs of Italy. The same could not be said for his successor, Francis I, who sent an army down into Italy and destroyed the Milanese army at the battle of Marigano. The French conquered Milan, and linked up with the Venetians. The league had fallen apart, the English had made peace with the French, and the Spanish were too exhausted to really do much. The Pope saw that he had been defeated and signed a treaty where in France gained Milan, and the Venetians gained all of their territory back. The Pope had to give some territory to a French allied Italian state. This was all confirmed in the Treaty of Brussels.
So 8 years after the original League of Cambrai had formed, the war came to an end in 1516. Not much had really changed. Venice was still strong, the Papacy had lost some territory, the French kept Milan, and the Spanish controlled Naples, and the Germans had failed to gain anything significant in Northern Italy. To answer your original question, the flip flopping came from the fact that the three main participants, the French, the Papacy, and the Venetians each wanted to expand their power, while keeping their neighbours weak. Thus when the balance of power shifted, so too did the system of alliances.
My two main sources for this were "A History of Venice" and "A History of the Papacy" both by John Julius Norwich. Also a good read, but a bit more dry is the book "Renaissance France at War" by David Potter.