The eye is filled with fluid and sometimes a little chunk of debris will occur in the fluid called a "vitreous floater".
People who have these floaters report spots floating before their eyes, and we presume that if a dog saw such a spot, she might snap at them thinking they were flies.