That dreaded flare also called veiling glare, is caused when stray light from the sun or any other bright light source hits the front element of a lens at an angle. The light will reflect off the interior glass surfaces of the lens elements and will create color artifacts and ghosting in the image.
Modern lenses are “multi-coated” which helps minimize flare, but can not eliminate the problem in its entirety.
A lens hood or other object like your hand or a hat can be effective in shielding your lens from stray light. Always use hoods designed for your particular lens or you will end up with another problem “vignetting” (dark corners on the picture.
Using your viewfinder to determine flare is the best way to ascertain if the lens hood is adequate. If not then addition shielding will be necessary – use your hand or some other material to provide a shield but not something that becomes a distraction in your image.
If you plan to include the sun in your photo (sunrise or sunset images or images where the sun is showing through the trees), you should expect some flare or ghosting.
You can further minimize flare by removing any unnecessary glass from your lens, UV and sunlight filters are examples.