Not taking sports injury due to incorrect posture into account, if the muscle is painful or sore after you do a workout, does it mean that your workout is effective?
No, not necessarily.
Muscle soreness after a workout is usually due to Delayed Onset Muscle Soreness (DOMS), or small tears in the muscle. As noted in this article on Stronger by Science, it's possible to have DOMS with little/no muscle damage, and possible to have a lot of damage without DOMS.
It also states that it may make subsequent workouts less effective because you don't exercise the same, and/or you skip workouts due to the pain.
There is some "bro effect" where people believe what they believe, but the science of it is not supported. You can get DOMS from extended endurance activities, which are not muscle building.
Read the article, then read the linked studies. It's interesting.