Collecting stars in Bad Piggies differs greatly from Angry Birds games: once you finish an objective in a level and get a star, you keep that star.
Each level has three different objectives. You don’t need to accomplish all three objectives at the same time or with the same machine. You might build one super-fast machine to get to the finish line quickly, then tweak that design so that you avoid using a particular object, and then steer carefully to avoid breaking the machine.
To collect all the stars you will need to think about what kind of a vehicle can reach which objective and apply your building and piloting skills to the fullest!