This tends to happen when the flight originates in countries where security is more lax than it is Europe & the UK. The stowaways climb into the undercarriage bay on the ground before take off. During the flight, because the undercarriage bays aren't pressurised, the stowaway loses consciousness. When the landing gear is lowered on approach, because the stowaway is unconscious (or most likely after a long flight deceased) they can't hold on and so fall out of the undercarriage bay.
As I said at the start, it only tends to happen when a flight departs an airport in a less security conscious country. Somebody breaking through the perimeter fence and making their way to an aircraft say in the middle of the night would largely go unnoticed. Also in some cases bribery may be used to sneak to the aircraft. The size of the undercarriage bays on long haul aircraft can be quite large - well large enough for somebody to climb into anyway.
As I said at the start, it only tends to happen when a flight departs an airport in a less security conscious country. Somebody breaking through the perimeter fence and making their way to an aircraft say in the middle of the night would largely go unnoticed. Also in some cases bribery may be used to sneak to the aircraft. The size of the undercarriage bays on long haul aircraft can be quite large - well large enough for somebody to climb into anyway.