Machanidas of Sparta's motive for attacking Elis was almost certainly territorial expansion, and was part of the last but one of several (ultimately futile) attempts to resurrect Spartan hegemony in the Peloponnese.
A final attempt to restore Spartan 'glory' was made a few years later by Machanidas' successor, the tyrant Nabis (ruled 207 to 192 BC). This also failed as Sparta, along with the rest of Greece, became a part of the expanding Roman domains.
Unfortunately, our knowledge of Machanidas is limited:
Who exactly Machanidas was, or how he managed to attain power, is not
clear – our sources label him a ‘tyrant’, but as Polybios is the
originator of that label it tells us nothing of how he was perceived
within Sparta. He may have been associated with the young Pelops, he
may have been a Tarentine mercenary. He certainly liked the trappings
of power, parading in a purple cloak, and he certainly pursued the old
grievances with Achaia, and campaigned actively, if not always
effectively, against the Achaian League.
Source: Daniel Stewart, 'From Leuktra to Nabis, 371–192'. In Anton Powell (ed.), 'A Companion to Sparta' (2018)
The infant Pelops (c.210 - 206 BC) was the Eurypontid King of Sparta for whom Machanidas may have been acting as regent. Much as King Kleomenes III had attempted some 15 years earlier, Machanidas was almost certainly trying to reassert Spartan leadership in the region. He came to power by 209 BC, possibly a little earlier.
As for the timing, Machanidas was likely taking advantage circumstances. The Romans, also allies of Elis, had withdrawn from the region after their attacks on the Achaeans and were thus not in an immediate position to stop Machanidas from attacking an ally:
Machanidas certainly wished to pursue an active military policy
against Sparta’s by now traditional enemies of the Achaean League. The
timing was opportune, since Roman forces outdid even the savagery of
Philip in their descents upon Achaean positions in the Peloponnese.
Thus probably in 208 Machanidas not only recovered the perennially
disputed Belminatis but actually captured Tegea, attacked Elis, and in
207 pushed on into the Argolis to threaten Argos.
Source: Paul Cartledge & Anthony Spawforth, 'Hellenistic and Roman Sparta'
By subduing Elis, he would have brought that state and its resources directly under his control rather than simply having an ally who might change sides later.
Philip V was, for his part, under pressure from neutral states (Egypt, Rhodes, Athens and Chios) to put an end to the conflict as it was disrupting trade. Also, in the 220s, it had taken the combined forces of the Achaean League and the Macedonians under Antigonous III Doson to end Kleomenes III's attempt to resurrect Spartan power. It would not have escaped Philip V's notice that Machanidas was trying to emulate Kleomenes III; the Macedonian king had enough problems on his hands without having to deal with a resurgent Sparta - better to stop the tyrant before he became a genuine threat. According to Livy, this was not the first time that Philip V acted to deter Machanidas: the Achaeans had asked for his help in 209 BC.
Machanidas, as it turned out, overreached himself; the Achaeans, who had been repeatedly beaten by Kleomenes III in the 220s, had been staging a recovery under Philopoemen and defeated Machanidas at the Battle of Mantinea shortly after the Spartan attack on Elis. In reality, Machanidas never had a realistic chance of resurrecting Spartan supremecy in Greece. Macedon was far too powerful, and even that would soon be taken over by Rome.