Can you prevent muscle soreness?
First of all, it is important how you train. If you are a beginner or have had a long break, it makes sense to start slowly and then gradually increase the workload. Warming up and stretching is generally useful and important to avoid injuries, but it will not protect you from muscle soreness if you overload your muscles. Stretching after a sore muscle can even be harmful and is only recommended after sufficient rest.