>>1713782"the back gear" as in it's a fixie/single speed? If the chain's got too much slack you should either adjust the tension by moving the back wheel farther back in the dropout (if you have that kind of dropout) or getting a chain tensioner. If it's really bad you could have to shorten the chain.
Other than that here's an article with a bunch of shit you can investigate:
https://mountaintreads.com/reasons-why-mountain-bike-chains-come-off/