How come "stick in the mud" has almost the same meaning as "headstrong"?
They do not have the same meaning.

someone who is headstrong will be opinionated, determined, a strong personality, maybe will over-ride other people's opinions and feelings a bit.

Someone who is a 'stick in the mud' is a conservative type personality, who may resist change, be a bit cynical and perhaps a bit dull and boring!

I suppose they both represent people who resist changing their views, but for completely different reasons.

And what is the etymology of "stick in the mud"?
Students: Are you brave enough to let our tutors analyse your pronunciation?
STICK-IN-THE-MUD from www.worldwidewords.org:

[Q] From Sara Lorimer: “I’ve read in a few places that stick-in-the-mud comes from the English habit of burying convicted pirates up to their necks in mud at low tide. This sounds unlikely, but intriguing. Do you know if this is true? And if so, how on earth did it come to mean a boring person?”

[A] Isn’t folk etymology inventive? Much more fun than boring old lexicography. Firstly, so far as I know there was never any such procedure for punishing pirates, or anybody else for that matter. Even in older times that would have been regarded as cruel and unnatural punishment. They were just hanged at Tyburn, like any other self-respecting criminal. Secondly, the more prosaic, but much more probable, answer is that it is just the most recent of a number of expressions of similar type implying being stuck in or held fast by something. Earlier examples were to stick in the briars and to stick in the mire, which were used for a person who has got himself into a difficulty or trouble from which he is having trouble extricating himself. Stick-in-the-mud seems to have been modelled on these earlier forms but was first recorded in 1733 with essentially the modern meaning: a person who is stolid and unimaginative, content with his lot and unprepared to make an effort to improve it.
Thanks, bmo!
you are welcome.
Teachers: We supply a list of EFL job vacancies
i think that someone who is stick in mind is very stubborn and don't like to listen to others opinion, but someone who is headstrong is very determined.