Most general descriptions of muscle function are explained from a reference of anatomical alignment.
Anatomical alignment is much like lying on your back, arms at your sides, palms up, legs straight, toes up.
When you begin moving out of such an alignment, joint angles and muscular functions change.
For instance, gluteus medius is primarily known as a hip abductor and external rotator.
In standing and walking, it will resist the hip’s tendency to adduct and internally rotate at the hip.
In a complex movement like a squat or a lunge, as the hip flexes its moment arm changes such that the muscle no longer abducts and externally rotates the hip but rather it becomes an internal rotator of the hip.
If you’re trying to correct someone’s lunge because their knee tends to “cave in” at 90 degrees of hip and knee flexion by strengthening their gluteus medius, best of luck because it won’t help due to the change in the muscle’s change in function. Look for a posterior chain weakness in this case.
Learning more about how a muscle functions throughout a joint’s range of motion will help to assure proper corrective strategies and exercise selection.
Bill