Let $n$ be an odd prime. I want to prove that the dihedral group $D_n$ cannot be written as a product of two nontrivial groups. But it seems problematic, as I completely neglect the properties of prime of the $n$ in my proof.
So, first of all, I'm using the fact that $D_n$ have some element of order 2, which are the reflections $r$ across its axes of symmetry. (Edit: I would like to credit Anne Bauval for pointing out my mistake here.)
Next, I'm assuming that $D_n$ can be written as a product $G \times H$ of two nontrivial groups $G$ and $H$, neither of which is equal to $D_n$ itself. Since $D_n$ is not abelian for $n \geq 3$, WLOG $G$ is not abelian. (I doubt this but I can’t think of a good reason for $G$ to be not abelian. Sorry if I made a mistake here.)
Now, I take a nontrivial element $g$ from $G$ and a nontrivial element $h$ from $H$. Since $G$ and $H$ are both nontrivial, $g$ and $h$ both have order at least 2.
Next, I consider the element $(g, h) \in G \times H$. Since $(g, h)$ is not equal to the identity element $(1, 1)$, it must have order at least 2.
If $(g, h)$ has order 2, then I have:
$$(g, h)^2 = (g, h) \cdot (g, h) = (g^2, h^2) = (e,e)$$
where the second equality follows from the fact that $G$ and $H$ are both groups, and the third equality follows from the fact that $(g, h)$ has order 2.
This implies that $g^2 = e$ and $h^2 = e$, which means that $g$ and $h$ both lie in the set of reflections of $D_n$, and hence must commute with each other. But this contradicts the assumption that $G$ is not abelian.
Therefore, $(g, h)$ cannot have order 2. But since $D_n$ has a unique element of order 2, namely $r$, it follows that $(g, h)$ cannot be equal to $r$.
This implies that $G \times H$ cannot contain all of the reflections of $D_n$, and hence cannot be equal to $D_n$ itself. Then it completes the proof (Did I?)
Sorry for the poor presentations. Could someone please take a look at my proof and let me know if there are any errors or if it can be improved? Thank you!
Your proof does not work (there are several irremediable mistakes, pointed in the comments) but contains some inspiring ideas, for a proof which works for every odd $n$ (not necessarily prime).
Suppose $D_n=G\times H$ where $|H|$ is odd. Then, $G$ (viewed as a subgroup of $D_n$) contains at least a reflection $s$ (either by Cauchy's theorem, or simply by contradiction: else, $G$ and $H$ would only contain rotations, hence so would $D_n$). Then, every element in $H$ is a rotation commuting with $s,$ hence $H=\{1\}.$
Note that when $n=2m$ with $m$ odd, $D_n\cong D_m\times C_2.$