So I have a Trek Fuel SLR 90 and whenever I ride on flat dirt roads, the back gears randomly keep switching on me. It gets really annoying to ride Please help
If its just up and down one gear then you probably need to calibrate the derailleur cage a little using the barrel adjusters. Depending on the make of shifter and derailleur there will be a barrel adjuster on one or both ends of the cable outer which will allow you to make micro-adjustments to the cage position.
The jockey wheel centre should be roughly aligned with the center of the cassette cog. What you might find is that the jockey wheel is slightly left or right of the cog at a given shift position (the one that is jumping) so use the barrel adjuster to eyeball the wheel to line up with the cog. It shouldn't take more than a few turns to do this.
Also if the barrel adjuster is fully extended or screwed in, you may have to release the cable at the derailleur end and move it in/out to give you some adjustment room before reattaching the cable.
On the other hand if you are getting more than one shift up or down something is seriously wrong and you may have to replace parts.