Right when Fievel finds the entrance to the sewer where the rats and the cats are meeting, he sets his hat down at the top of the metal grid that filters out large items so that he can climb into the sewer. It then shows him walking at the bottom of the sewer without his hat . A few moments later, it shows him again holding the hat.
There are several parts throughout the movie where Fivel sticks the hat in his back pocket(or in his belt). When he does this you can still see it a little bit. I don't know if this is what happened in the scene you described or not. Really good eye though, I've seen the movie a countless number of times and never noticed that!