Sounds like the freehub/freewheel is having problems engaging the pawls.
The freehub is the component in the middle of your rear wheel, and goes between the hub and the cassette. If your bike is older, the same task might be done by a freewheel which is integral with your cassette/cogs.
Note you can look up all these parts in the Terminology Index
Here's a great photo showing what pawls are inside the freehub/freewheel.

As you pedal, the outside ring rotates clockwise, and the four little levers are caught, transmitting power to the middle part and driving the rear wheel around. When you stop pedalling, the outer ring stops, and the inner is driven by the ground via the wheel, and the click-click-click is the noise of the pawls tapping around the recesses.
In your case it sounds like the pawls are not fully engaging, and leg-power is enough to unseat them. Your options are
- Bounce the bike hard, or tap the axle with something solid like a rock or hammer - very temporary fix that may help you get home again.
- De-grease the inside of the mech by liberally soaking with degreaser. Sometimes the valleys can be gummed up by dried lubricant, and soaking it out helps. This is horribly messy, and will contaminate any brakes so remove the wheel from the bike, and the rotor from the hub first. Or you can remove the cassette and freehub or the freewheel from the rear wheel, with specialised tools.
- Disassembly - I've never had much luck with disassembling either freewheels or freehubs. There could be a hundred very small bearing balls inside there, and they never go back together right in my experience.
- Replacement
- A freewheel is cheap enough, just buy a new one with the same number of cogs and the same tooth counts. You'll need a new chain too.
- A cassette can be reused, but there are a lot more possible fitments for the freehub on the inside
- Third option can be to fit up a used replacement wheel, of the same size from a donor bike. A New wheel tends to be quite expensive, and is not economic.