|MadSci Network: Astronomy|
Strictly speaking your questions have no certain answer, but they have very probable answers. Scientific knowledge is never absolutely certain, and changes along time. Current theories on the origin of planetary systems hold that planets form from the same cloud of gas and dust in space that formed their central star. These theories are based on observations of disks of gas and dust around young stars. Calculations done with powerful computers show that after a star forms from the collapse of a piece of cloud in space, there is always some remnant material in the shape of a disk rotating around the recently formed star. Planets form when small condensations form in the disk and attract more material until most of the gas and dust in the disk have been swept by the planets and other bodies like asteroids.
This is a picture of a disk viewed edge on around a star slightly bigger than our Sun, called Beta Pictoris. It was taken with the Hubble SpaceTelescope by Burrows and Krist in 1995. The image above is how it looked with the camera on board the telescope and the image below is the same image with colors added according to the intensity of the light: red is brighter light, blue is fainter, and yellow shows middle intensities. The glare from the star was blocked with a circular disk at the center. This disk looks warped, that is, the central part of the disk lies in a different plane from the rest of the disk. The warp may be caused by a big planet orbiting around the star. You can see the full explanation of this picture at the NASA Hubble Space Telescope site (Credit: Chris Burrows, Space Telescope Science Institute (STScI) the European Space Agency (ESA), J. Krist (STScI), the WFPC2 IDT team, and NASA).
This is an artists conception of the theory of planetary system formation from the NASA Origins site. You can find educational material on planet and star formation here too . The new star is forming at the center from material that falls from the rotating disk while planets form in the outer disk.
The possibility of the Sun grabbing planets from another star or vice versa is very unlikely because the planets would be left in very elongated orbits around their new star. The orbits of planets in our system are almost circular and they lie almost in the same plane. Such orderly motion for all eight planets (Pluto is no longer considered a planet) can most easily be achieved by a formation of planets within a disk of gas and dust around the Sun. When a star forms out of a cloud, the gas and dust of the cloud must rotate in circles in a disk around the new star. Otherwise the gas and dust cannot fall upon the forming star.
As I said before, it is very unlikely that a star captures planets from another one, not only because the newly formed planetary system would be left in total chaos, with some planets crashing into each other and others being left in very elongated orbits, but because close encounters between stars are very unlikely. There is a lot of space between stars, and the possibility that one star comes close enough to another and pull its planets is very small in most parts of the galaxy. The only possible exception are globular clusters that have millions of stars crammed in a very small space, but those are far away from the Sun in our Galaxy. However the fate of Earth and most planets near the Sun (Mercury, Venus and Mars) is not a live-happily-for-ever one. Before the Sun dies, it is going to grow in size until it swallows the Mars orbit. All planets in between will be melted down and engulfed by the Sun. This will happen because the fuel that powers the Sun, which is hydrogen at its core, will run out. The core will shrink, and paradoxically that shrinking will make the core produce more energy that the outer layers of the Sun must compensate by expanding. I know this sounds hard to understand, my graduate students are struggling to understand it too, but stellar physics says so, and computer simulations concur with this scenario. When the Sun finally dies, outer planets and bodies in the outer solar system, if they survive the hecatomb, will continue to orbit the dead Sun because the Sun gravity will still be at work. Remember that planets orbit the Sun because the gravity force attracts them to the Sun, and gravity depends only on the mass of the bodies. But the expansion of the Sun into a red giant will happen about 5 billion years from now, according to current calculations. We have time enough to worry about more pressing problems on Earth.
Vladimir Escalante Ramírez
Try the links in the MadSci Library for more information on Astronomy.