Here's how I think it works:
Technically, you need permission to use any assets that aren't yours. Using them anyways is bad even if you give proper credit. So all this fan-made stuff we make is technically illegal, and they could have our entire site taken out if they want. We could ask for permission but good luck asking, and good luck getting them to say "yes".
Thing is, companies probably don't care about fangames. There have been fangames that the companies approve of, and there have been fangames they've taken action against, but these are special cases. A company isn't going to stop a small group of people from making one little game not all of their customers are going to play or even know/care about - why take action against us when it's not harming them? It'd waste time and money.
Now, if you SELL a fangame, THEN that draws their attention because us making money off their assets doesn't sit well with them. It's why that MLP Fighting Game was C&D'd and it's why companies are starting to want a cut of ad revenue on LP videos.
Hopefully that sums it all up. Short version: There should be no issue with fangames as long as you don't profit from it.