I've taken apart some N64 controllers and replaced sticks before. The analog stick is a separate module that screws in to the front (you might see this if you have a translucent one). There is no real way to repair a stick module, as normal movement wears at the plastic bezel in it and creates play. The tolerances are pretty tight, I think if you tried to put a shim in it or something, it wouldn't work well. You can get a NOS module from someplace like [http://vpgames.com/p-15490-aftermarket-n64-thumbstick-thumb-stick-replacement-for-nintendo-64-controller.aspx?utm_source=Google&utm_medium=Froogle&utm_campaign=DN64R-A02|HERE].
The way to get at it is somewhat simple. Unscrew the 9 Phillips screws on the bottom of the controller (7 in plain view, two smaller ones in the Controller Pac slot thing). Separate the two halves, and be prepared to catch the shoulder buttons. Once inside, unclip the blue membrane switch for the Z button from the underside of the module. Unplug the connector that goes to the bottom right part of the board. Unscrew the three silver screws holding the module in (NOT the black one, because the whole module will let go into two halves and fly apart from spring tension) and lift the module out. You can fiddle with it if you want, but I advise ordering a new one. You can continue taking it apart if you want to clean out the buttons and stuff, but be warned as all the buttons will fall out once you take the mainboard out. Also the chip in the dead middle of the top of the board is susceptible to static damage, so be careful there.
Some stuff about the technology it uses...the type of sensors in it are optical, not potentiometers (variable resistors) like modern sticks...optical sensors are similar to old ball mice, in which the ball moved rollers around that were attached to gears, and the gears to wheels with slits cut in them. The wheels sat between a infrared emitter and sensor, and how fast the slits went by told the sensor how fast the roller was moving. There were two rollers (there was a third one, but that's just for tension), so it could get X and Y values.
The N64 stick works in a very similar way. The part of the stick you don't see goes through two hoop type things, one on top of another, and oriented opposite ways. When you move the stick straight vertical or horizontal, it only moves one of the hoops. The axles that the hoops rotate on are connected to the gears and such. This is how the logic of the controller gets values for X and Y. And, of course it has a big spring for centering and resistance, and a bunch of other stuff I'm not sure what it does.
I hope I've clarified things and helped you with your controller problem.
Justyn