How to fix problem with mountain bike chain falling off gears?
Yeah, first clean the rear derailer well.  Simplest way to do this is to lean the bike against a wall (outside, where you can make a mess), slide some newspapers up behind the derailer and drape them down the the wheel (to keep from dripping all over the tire), then spray the derailer well with WD-40, using an old toothbrush to clean it up a bit.

Afterwards, wipe the derailer dry, then oil it up well with a heavy oil (preferably bike chain oil).

If the bike has more than maybe 2000 miles on it then likely the chain is worn out, and possibly the rear sprockets have developed a "hook".  A bike shop can check for this with a special gauge, and replace the chain if it's too badly worn.  (If "hook" has developed a new chain will help a bit, but the rear sprockets may need to be replaced.)

Regardless, likely the rear derailer is out of adjustment.  It's not very complicated to adjust, but it takes a touch of mechanical ability to understand which way to turn things.  But mainly it's a matter of adjusting the cable tightness, which is usually done by turning a knob on the cable near the shift lever or elsewhere along the cable route.

The other odd possibilities for this problem are that spring has broken in the derailer (or sometimes the spring has just "jumped" off the tang where it's supposed to be hooked), or some jackleg replaced the chain and didn't get the length right.