A planet can form in a different location and later be captured by a star due to gravitational attraction.