A fanfilm is exactly what it sounds like... a film created by a fan of some sort of pre-existing property... Some make fanfilms from comic characters, others use films (such as Star Wars or Star Trek) as the basis of their films. The legal implications are simple: it's copyright infringement if you attempt to sell, in any way, your fanfilm. This is because you are using licensed characters without permission from their creator/owner.
So, fanfilms are made for pretty much one of two reasons:
1. Because it's a fun way to pay tribute to a property to grwatly admire.
2. It's a good way to showcase your abilities as a storyteller.
You cannot enter fanfilms into festivals, and you cannot profit from them in any way.
Sometimes the owners of the different properties will hold contests for fanfilms. Lucas did this a while back, showcasing different short Star Wars fanfilms and/or parodies. But most of the time, the owners of the properties don't even acknowledge the fanfilms that are made.
Hope this helps!

~ Stephen