I heard a couple of years ago that only certain types of lens caused flare to appear, something related with the material and/or quality of the lens. Is this true? Which material/quality caused flare? Thanks in advance.
Uncontrolled light causes lens flare. This can be light that's reflected from internal lens surfaces, or that's scattered by imperfections in the glass.
If the flare is badly controlled, it will produce the dramatic lens flare artifacts which you've probably seen. More controlled flare will be diffused over the entire image, reducing contrast but not producing other visible artifacts.
Flare can be controlled in several different ways. A simple way is just to prevent non-image light from hitting the front element in the first place. Avoid putting bright lights (the sun, for example) directly in the frame, and prevent out-of-frame light from shining onto the lens. This is what a lens hood does — or, simply shading with your hand, in a pinch.
If there is a bright light source (the sun, for example again) that you want to have in your photograph, that's not going to help. That's a reason wide angle lenses are more susceptible to flare (and for the same reason, a lens hood can't be as useful, as a deep one would block the actual image).
On almost all modern lenses, special optical coatings are applied to the lens to help control the stray light. These are made of various metallic and mineral compounds which alter the way the lens transmits light, and they're specially chosen to reduce the unwanted scattering of light. More expensive lenses use more expensive coatings, and more expensive optical elements which have less of a problem in the first place. Lenses also have internal baffles designed to reduce bouncing light.
Cheap filters often have cheap coatings, and since they're often more exposed than the front element was, they're more prone to catching stray light. That's why adding a UV filter for lens protection can reduce image quality.
So, to answer your question directly: yes, it's true. Flare is caused by stray light, not by lens materials directly, but cheap lens materials can make it worse and high-quality ones can mitigate it. Even with a cheap lens, you can make things much better simply by using a lens hood or standing in the shade, and keeping the sun out of the frame.
Basically, it's reflections.
Inside a lens, you want the light to travel from the front of the front element, to the back of the rear element, without bouncing off any surfaces.
There are two main surfaces, however, that light may bounce off.
Whether or not your lens' flare is noticeable depends not only on the lens assembly, coatings and filters, but also on the subject material you are shooting. Where you are shooting near bright lights or direct sun, you're more likely to notice the flare. This is particularly true if you point your camera towards light sources or the sun - even if they're not actually in the frame (you can use a hood to help reduce that particular problem). If the lighting around you is more soft and diffused without direct sun, then you're less likely to see any noticeable flare simply because it won't be well defined compared to the rest of the image.
Lens flare is caused by a bright light source (such as the sun) shining into the lens (whether in the image or not) that has its light reflected and scattered inside the lens causing a wash out or a flare artifact. All lenses will be subject to this to a greater or lesser degree, but this most commonly manifests with wider angles.
There are mitigation steps taken with the lenses themselves and these include:
In any case, higher quality lenses often have better coatings and more defense against lens flare. Also, it's sometimes desirable and can be used for artistic purposes, so it's not always a bad thing if you do it consciously.