An index fund (like one that tracks the S&P 500) holds hundreds of companies at once. If a few do badly, others can make up for it.
This diversification is why index funds are a common first investment. They are low cost and you do not have to pick winners.
One common plan is to buy a broad index fund on a regular schedule and hold it for years. Whether that fits you depends on your goals and how long you can wait.