Galois group of a reducible polynomial over $\mathbb {Q}$

Let $f \in\mathbb {Q}[X]$ be reducible - for the sake of simplicity, $f = gh$ with $g,h \in\mathbb {Q}[X]$ irreducible. Let L be the splitting field of f.

Does $Gal(f) \simeq Gal(g) \times Gal(h)$ hold, were Gal(~) denotes the galois group of the splitting field of the respective polynomial?

From what I understand, every element in the Galois group of g may be (not uniquely) extended to a homomorphism from L to $\overline{\mathbb{Q}}$ since L is an algebraic extension of $\mathbb{Q}$, and because L is galois ($\implies$normal), this extended homomorphism maps L to L, thus, it is an element of Gal(f). So, $Gal(g) \subset Gal(f)$.

I also know that Gal(f) cannot act transitively on the roots of f since f is reducible. Since Gal(g) acts transitively on the roots of g and because Gal(g) embeds into Gal(f), there cannot be an automorphism in Gal(f) mapping a root of g to a root of h, because if such an automorphism existed, I could permute all the roots of f in any way I wanted, which is not possible.

However, I don't see how I can solve the problem I stated in the beginning from here.

Your argument shows that $\text{Gal}(f)$ is contained in $\text{Gal}(g)\times \text{Gal}(h)$, since it sends roots of $g$ to roots of $g$ and roots of $h$ to roots of $h$. The simplest example that shows that you cannot expect equality in general is $f=g^2$. Clearly, in this case $\text{Gal}(f)=\text{Gal}(g)$. More generally, equality holds if and only if the splitting fields of $g$ and $h$ are disjoint over $\mathbb{Q}$. Note that this is stronger than $g$ and $h$ being coprime.
Exercise: find two distinct irreducible polynomials $g$ and $h$ whose splitting fields are not disjoint over $\mathbb{Q}$.
• How about $f = X^4 - 2$ and $g = X^2 -2$? Both are irreducible over $\mathbb{Q}$ (Eisenstein). The real number $2^{1/4}$ squared yields $2^{1/2}$, thus the splitting field of g is contained in the splitting field of f. Anyways, thanks for your answer, how silly of me to overlook that counterexample.