It all depends on the airplane in question.
Typically for small GA airplanes using an electro-hydraulic power pack for actuating the gear, they’re held retracted by hydraulic pressure. If the system fails, the pressure goes to zero and the gear just drops down due to gravity. I have time in the DA-42 and DA-62 twins and those airplanes use an alternate gear extension handle - basically an emergency valve which releases hydraulic pressure and allows the gear to drop down on their own.
Electrically powered landing gear can be typically lowered by means of a hand crank in the cockpit. This is prominent on Mooneys and light Cessna twins.
Larger airplanes and jets may make use of emergency reservoirs of compressed nitrogen called blowdown bottles to provide emergency hydraulic pressure and extend the gear. Typically the landing gear retraction jacks can be isolated from the main hydraulic system via a cockpit switch to prevent total loss of hydraulic fluid in the event of a leak. It also removes the additional workload from emergency systems eg APU, RAT, etc. for more critical flight control functions.
Transport category airplanes often have multiple layers of redundancy ie multiple hydraulic systems and power sources to get the plane down safe.