In this deleted scene from Episode 3, you can see that Yoda landed on Dagobah in an evacuation pod. The "Star Wars: Complete Cross-Sections" describes it as an E3-Standard Lifeboat that was dropped from Bail Organa's ship.
The Star Wars Databank described it thusly;
Having failed to stop the Emperor and realizing that the galaxy had
grown to be a dark and deadly place for any surviving Jedi, the
revered Master Yoda fled into exile at the tragic end of the Clone
Wars. Aboard a star-shaped escape pod [a 3.5 meter diameter E3-standard starship lifeboat E], he journeyed to the obscure
world of Dagobah. As the pod settled down on the marshy surface of the
shrouded bog planet, its hatch opened and Yoda surveyed the grim
surroundings. This would be his home for over two decades.
The pod was not capable of interstellar flight (or reaching orbit from the ground) which means that Yoda was effectively stranded although it's reasonable to assume that the lifeboat contained some kind of transmitter or emergency beacon, allowing him to be rescued the surface, should the need arise.