Its largely comes down to quality of the bike, which comes down to price, and your size and strength. A well build bike with quality gear set should not do this. A cheap bike, especially a folder, with entry level gears its not entirely unexpected. If you big or strong (or both) the problem is worse
The problem comes from frame flex. The gear spacing on the rear cluster is about 5mm, and the chain is around 8mm wide, the amount of movement needed to initiate a gear change onto the next cog can be as small as a millimeter. When a rider cranks hard on a flexible frame, its easy to get enough flex to cause a gear shift to initiate.
This is flexing not normally considered a big problem - high cadence (pedal revolutions) with lower force is much better riding style than 'mushing' at low cadence. Flexing is not desirable for a number of reasons, so experienced cyclists tend to ride bikes with stiffer frames.
Folding bikes are always going to be compromise as its hard to make a folder stiff. It may be that a folder is not for you and you would be better with a non folding bike, or you may decide to change your riding style to suit the limits of the bike.
Ultimately any modern derailleur type bike is a finely tuned, precision machine. While they are reliable and can last a very long time, they are far from being indestructible. When poorly ridden they are almost certainly going to fall apart.