The Solar System isn't always layed out in a neat line like in your 8th-grade textbook. They're each orbiting the Sun at different rates, which puts them in different places. It is entirely possible (though admittedly less common) to see both Earth and Jupiter from Mars at the same time.
Here's a diagram showing how:
https://petapixel.com/2012/08/26/earth-and-jupiter-seen-in-a-single-photo-taken-from-mars/
Here's a diagram showing how:
https://petapixel.com/2012/08/26/earth-and-jupiter-seen-in-a-single-photo-taken-from-mars/