The muscle would have to move to a different bone to produce both actions.
The contraction of a muscle that is acting as a flexor is different from the contraction that produces extension.
A single muscle would not be strong enough to produce both actions.
A muscle can pull at a joint only through a contraction. Because muscles cannot push, a different muscle is required to move the joint in the opposite direction.