This idiom originally meant to befool others with tricks. Later it is used to mean to keep changing one's mind.
In Iran the same mischievous propaganda is at work to befool the rather ignorant-or less knowledgeable-public that it poses a threat and is a fanatic, terrorist country.