You do have to experience discomfort to grow stronger. There is no doubt about that. The exertion you feel when you exercise is stress on your muscles. When your muscles are stressed past the point which they are regularly subjected to, they grow stronger in the repair process. So you do have to experience some low level of pain or discomfort when you exercise to see results.
However, when the pain is noticeable, this could be your body talking to you. You may have sustained an injury which is not outwardly noticeable, but has done significant damage. If you continued working out during that session, and possibly even the next couple of days, you could do long-term, serious damage. While healthy progress is needed to keep your body improving physically, pushing through the pain is usually not a smart thing to do.
There is a difference between pain and soreness. If you started your workout program very simple and with little exertion and have constantly, continually but slowly improved your level of stress and your duration of exercise, you are going to feel sore. That is your body becoming stronger. This is the repair process. This is normal, and it is a sign that you are building a stronger, healthier body.
Pain is different from soreness. If you have ever suffered a paper cut, that is a low level of pain. That is different from the feeling you get from sore muscles. Pain is a big, red warning flag to stop exercising. You should never push through physical pain. This is because of how your body handles pain.
If you are in a life or death survival situation, by all means, attempt to outrun that grizzly bear even though you have a broken leg. When you are exercising, this simply is not needed. Because of the way your body compensates for injuries, the adjustments your body makes to minimize the pain you feel can lead you to put more stress and strain on other body parts. These small compensations build up and can possibly cause another injury, even though they are initially designed to limit your pain from the first injury.
Pushing through pain can also cause you to develop, and unconsciously embrace the poor form. You probably know that, especially with strength training, 3 to 5 repetitions performed with perfect form will out produce 8 to 12 repetitions with sloppy form. As your body understands you are injured and begins to compensate for that injury, your form can suffer. If you get through the workout and feel good about pushing through the pain, your mind may unconsciously adopt this new, sloppier form as its regular practice.