So the solution of the exercise is as follow:

is this not a mistake?? The exercise says that the two groups are normally distributed. It doesn't say anything about them having the same variance. All the working out done in the question is the typical one that we use when we have two normal samples with different means and same variance and we want to check whether they have the same mean. But this is clearly not that situation.
Can we still use the same procedure? And if it is correct, why is it?

Excellent question. This is an old problem called Behrens-Fisher Problem. If the variances for the two normal populations are unequal, no known exact test exists. Asymptotic tests, however, are known. It is an open problem to find a test statistic for all $n$ having suitable null distribution if the variances differ.