They were telling you not to fight against imaginary foes. It comes from a story by Cervantes called Don Quixote de la Mancha, published in the early 17th Century. Don Quixote is an amiable old idiot who rides around in a rusty suit of armour doing daft things, including 'tilting' (poking his lance) at windmills, because he thinks they are giants out to get him.