During the Punic Wars, the Macedonians allied themselves with the Carthaginians with the expectation they would be the victors of the war and therefore be on good terms with them in the future. In order to cement this, the Macedonian–Carthaginian Treaty was signed in 215 BC as recorded by Livy.
On this contest, between the two most powerful people in the world, all kings and nations had fixed their attention. 2 Among them Philip, king of the Macedonians, regarded it with greater anxiety, in proportion as he was nearer to Italy, and because he was separated from it only by the Ionian Sea.  When he first heard that Hannibal had crossed the Alps, as he was rejoiced that a war had arisen between the Romans and the Carthaginians, so while their strength was yet undetermined, he felt doubtful which he should rather wish to [p. 876]be victorious.  But after the third battle had been fought, and the third victory had been on the side of the Carthaginians, he inclined to fortune, and sent ambassadors to Hannibal. Livy 23.33
With the alliance in place, the Romans would have to further stretch their forces and resources to the east so as to counteract any possible Macedonian offensive.
The Macedonians had numerous things to gain from the defeat of Rome:
It would curb Roman expansion efforts into Illyria which had been happening prior to the Punic wars and threatened the borders of Macedon
it would stop the Roman money coming into the independent Greek Poleis which had been used to foster opposition towards the Macedonian kings and weakened their military supremacy in Greece.
And furthermore, the treaty assured that once all of Italy was under Carthaginian rule, the Carthaginians would aid Macedon subdue her enemies in the east:
That when Italy was completely subdued they should sail into Greece, and carry on war with such nations as the king pleased. That the cities on the continent and the islands which border on Macedonia, should belong to Philip, and his dominions.”
The carrying out of a Macedonian-Carthaginian alliance was heavily promoted by the court councilor Demetrius of Pharos who had been the last ruler of Illyria before the Romans defeated him in 229BC. Demetrius according to Polybius had much influence on the Macedonian king and urged him to invade Illyria to re-establish him since the Carthaginians had been defeated.
Demetrius has been recorded saying to Philip V:
For Greece is already entirely obedient to you, and will remain so: the Achaeans from genuine affection; the Aetolians from the terror which their disasters in the present war have inspired them. Italy, and your crossing into it, is the first step in the acquirement of universal empire, to which no one has a better claim than yourself. And now is the moment to act when the Romans have suffered a reverse. Polybius, 5.101
So it was Demetrius and Phillip's threat to Roman occupied Illyria and also to Italy itself which prompted the Romans to intervene militarily.