Only a player on a team can catch a homerun ball. If a fan catches it like in the gif then it is still considered a homerun. There is a famous Chicago Cubs play involving similar circumstances, where a fan (named Steve Bartman) took a foul ball away from a Cubs player (Moises Alou) who was about to catch it for an out. In other words, the fan caught the ball and stopped the baseball player from catching it, making it a foul instead of an out. Following that play, the Cubs then proceeded to have many errors and eventually choke to the Marlins in the playoffs, keeping them out of another World Series. Sorry about the rant, I'm a big Cubs fan. Anyways, there is your accidental learning for the day into the great sport of Baseball.

The batter was on the Tampa Bay Rays and the fan that caught it was a Texas Ranger's fan. Usually when someone from another team hits a home run the fan throws it back. It shows support for the home team I guess.