Direct factor is transitive

Statement
Suppose $$G$$ is a group and $$H \le K \le G$$. Suppose that $$H$$ is a direct factor of $$K$$ and $$K$$ is a direct factor of $$G$$. Then, $$H$$ is a direct factor of $$G$$.

Related facts

 * Direct product is associative up to natural isomorphism
 * Direct product is commutative up to natural isomorphism