Good pain & Bad pain

If you have done lots of sports and gym classes, you maid heard expression : push through the pain. I heard it even in Yoga classes on 90 s. Thouth in certain extend it can be useful when building up muscles, however risk of getting injured is real.