This is a great question! I wonder what inspired you to ask.
It is very difficult for us to judge Achaemenid Persian foreign policy and its motivations, because these things are almost exclusively described to us by Greeks. Even though some Greeks had access to the Persian court as agents, doctors or diplomats, and might even try to influence the Great King's decisions, they couldn't help frame Persian decisions in their own Greek-centred understanding of the world. As a result, it's hard for us to really know what the Persians aimed to achieve, and what means they had available to do so.
What did the Persians want? As a baseline throughout the Classical period, the Persians wanted a stable western frontier to their empire. This western frontier had at least 3 notorious trouble spots: Egypt, Cyprus, and the Greek states on the coast of Asia Minor. For most of the period of 480-334 BC, at least one of these regions was in revolt or under outside rule. Sometimes they were all causing trouble at the same time. This put a huge strain on Persian military resources and often forced them to prioritise ruthlessly and choose policies that would not seem optimal in better circumstances. In particular, they seem to have decided fairly early on in this period that the focus of their own military activity should be Egypt and Cyprus, meaning that control of the distant west had to be handled on a shoestring budget.
But, as John Hyland has recently argued in his excellent book Persian Interventions (2018), Persian activity in the Mediterranean was not just defensive. On several occasions they clearly went much further than they needed to in their support of Greek states, showing that they would not restrict themselves to the bare minimum that was required to maintain the status quo. Persian support for Sparta in the Peloponnesian War and for Athens in the Corinthian War went much further than simply balancing foreign powers against each other to allow Persia to keep control of the Greeks of Asia Minor.
Instead, these campaigns should be seen as active attempts to assert the Great King's ancient claim to world empire. Ideologically, the Persians claimed the right to rule the world, as ordained by the great god Ahuramazda. Their holy mission was to bring order and justice to all peoples. Within this ideology the existence of any autonomous state outside Persian control was unthinkable; it was a lie against divine truth itself. In practice, of course, there were hard limits to Persian power. But it was always justified for Persian kings to seek to assert themselves beyond those limits, and to seek power over peoples beyond the borders of the empire.
This is a long preamble to the actual answer, but it is relevant background when we come to the real question: was the apparently chaotic policy of playing off one Greek power against another an effective way to reach these goals?
It is crucial to understand that the Persians were not simply giving weapons (trireme warships) to random Greek states with a note saying "Have fun!" The changing relations between Persia, Sparta and Athens reflect the changing power dynamics and policies of those states as well as the situation in which the Persians found themselves at the time. Each of their decisions to back one Greek power against another makes sense in its specific context. But there is also an overall thread of Persian attempts to assert control over the Aegean, and in this, I argue, the Persians were largely successful.
First, after the defeat of Xerxes in 480 BC, the Athenians (with their own self-funded fleet) managed to strip away most of western Asia Minor from Persian control. The Athenians also campaigned extensively in Cyprus and Egypt. This was the first time the Persians had suffered a durable loss of control since the rise of their empire. They responded effectively, repeatedly reclaiming control over Cyprus and Egypt and probing Athenian control over the Greeks in Asia, but in the end they seem to have settled for stability over reconquest. The treaty they allegedly made with Athens in 449/8 BC has often been interpreted as a concession of permanent losses (ceding control over the entire coast of Asia Minor) but it is probably better understood from the Persian perspective as the incorporation of a "free" Athenian Empire as co-guarantor of peace in the West. In this state it was often unclear to which side specific states on the coast belonged, and some were apparently paying tribute to both. Persia was fine with this.
But the balance was upset when the Athenians lost half their fleet in Sicily in 413 BC and most of their subject allies revolted. Suddenly a gaggle of independent actors sprang up, fleets were sailing up and down the coast, lands were ravaged and cities sacked. In its search for new allies, the Athenians backed a rebel satrap in Asia Minor. The Persians had to step in to restore order. It is at this point that they decided to back the Spartans, build a fleet for them (which they lost), build another fleet for them (which they also lost), then build another fleet for them which they used to dissolve the Athenian Empire. This was not about establishing "balance" so much as it was about picking and cultivating a state across the Aegean that seemed more capable of securing what the Persians wanted, and earning its fealty in return.
The problem was that Sparta did not behave as intended. They backed a pretender rather than the rightful king, and they waged war on the Persians to secure the "freedom" of the Greeks of Asia (really, the better to rule them and levy tribute from them). For several years (399-395 BC) the Spartan Empire waged a desultory war on land against the Persians in Asia Minor. Artaxerxes II decided it was time for the Persians to get personally involved to restore order. The fleet he sent to confront the Spartan fleet (built by the Persians, but now rebellious) was their own, even if it was partly manned by Athenians and had an Athenian general named Konon as its second-in-command. This new fleet defeated the Spartans at Knidos in 394 BC, crushing all Spartan hopes of retaining an empire overseas, while an alliance of Greeks on the mainland kept Sparta busy there. But the Persians did not simply leave it there and reclaim control of Asia Minor. They actually crossed the Aegean, raided the Peloponnese, and helped Athens rebuild its walls. Again, they were offering real support for their ally beyond what they needed to secure their own aims.
Unfortunately, once again, things did not go as intended. When the Persian satrap Tiribazos suspected the Athenians of abusing Persian support for their own ends, he imprisoned Konon and secretly began to negotiate with Sparta. The Athenians were outraged, lost faith in their great protector, and began to look after their own interests in earnest. This involved two of the things that had previously made the Persians nervous: levying tribute from the Greeks of Asia and the islands, and seeking allies among local rulers who pursued policies independent of Persia. It was when Athens backed the rebellion of Evagoras of Salamis (on Cyprus) that Artaxerxes decided his former policy of using them as his agents had to be abandoned. They were now causing more trouble than they were worth. But since he now had to deal with a revolt on Cyprus on top of an already existing revolt in Egypt, it was impossible for him to commit Persia's own military might to settle the matter.
By now, though, the power of the Persians to tip the scales with money alone was abundantly clear, and the mere threat of it was enough to force the Athenians and the other Greeks in line. The Persians offered money to the Spartans to build a new fleet which would threaten Athens' lifeline - the grain trade through the Hellespont. Fighting this fleet would have been ruinously expensive for Athens, which was already financially on the ropes for having to wage its war without Persian aid. So this fleet decided the Corinthian War (395-386 BC) with a treaty that was effectively dictated by the Great King. He got to resume levying tribute on the Greek states of Asia Minor, and the rest of the Greeks had to reckon with the very real threat of Persian support for their enemies if they ever stirred up trouble again.
The method to this madness is hopefully clear. The Persians were prevented either by military defeats or preoccupation elsewhere from conquering the Greeks outright. But they were fine with this as long as they could maintain a network of client states that secured the stability of their borders. Every single instance of them supporting a Greek state with ships and money was a response to a momentary failure of that system, and an attempt to replace one leading client with another. For the duration of this strategy, it was mostly effective, because it maintained and even expanded Persian control in the region while preserving Persian manpower for campaigns elsewhere.
But the end of the Corinthian War shows that Artaxerxes was fed up with the unreliability of Greeks as agents of the peace he desired. Every time he backed one, it would go off the rails and attempt to establish an empire of its own, which caused instability. The King's Peace was a response to these repeated disappointments and an attempt to break the cycle. It declared that no Greek state could henceforth rule over another, and all must be free and autonomous. This prevented any Greek state from forming an empire that could destabilise the Aegean, as first the Athenians and then the Spartans had done. It proved extremely effective: the Greeks were permanently divided by this ideologically acceptable form of subjection to the will of the Great King, and Persia ruled over the Greeks in Asia until the rise of Macedon proved a destabilising factor of a whole new kind.
So this whole post-Peloponnesian war period is full of swapping alliances, seemingly muddled loyalties, and is generally difficult to follow from someone who isn’t embedded in the history. Although, to be honest, the whole preceding century isn’t too far from this as well.
For sources, look at a combination of Thucydides, Xenophon, diodorus and Plutarch.
There is a theme that is very evident in the 4th century bc, (particularly within the series of “kings peace”, an enforcement of a general peace in the Greek world as sponsored by the Persian kings, and in the third sacred war, which surmounted to a huge, long conflict that took place in central Greece), of individual states/ kingdoms ruthlessly pursuing their own strategic agendas and not really caring who they used to get there.
As a result, you can’t really frame any insights of a state’s behaviour in the term of “sides”, such as good versus bad, freedom fighters vs conquerors. It’s best to look at actions in the context of if they deliver that state’s strategic aims. For instance, Athens were overwhelmingly concerned from the 5th century and all through the 4th with securing their grain supply coming in from the Black Sea. As a result, they worked with anyone and everyone to secure their control over the city of amphipolis, which sat at the north of the Aegean, to ensure that. Sometimes this was with old friends, other times with old enemies.
With that in mind, let’s look at the strategic objectives of the persian kings.
A peaceful north west border of their empire, where they werent suffering from incessant invasions and raiding.
A stable Greece to provide them with pool of mercenaries to use in their own wars. Greeks knocking the daylights out of one another limited that.
An easy to control, single hegemon within Greece to keep the other independent states in line, and so stop a handful of disruptive individuals from undermining the other two strategic aims.
If you consider the flip-flopping in funding and backing from the Persian kings in the terms of delivering those three strategic objectives, their actions make a lot more sense. So to answer your question, brilliant geopolitics for managing their strategic objectives in the short term, but undermined by a failure to consider that an actor outside of that system, ie Macedon, would become a big enough issue, or that the benefits of taking from Persia what it could not defend wouldn’t outweigh what the Persian king was willing to give.