I can’t speak of the other services but in the Army you always get to pick which job you want. It’s in your contract and you know what you are getting. The recruiter may attempt to steer you towards jobs that have shortages but it is still your choice. Of course the shortage MOS will have incentives like signing bonuses and what you want may not. Also jobs with longer and more complicated training up front may require a longer commitment.
It is hard to nail down specifics because it will change from month to month depending on shifting needs. But you always get a choice going in and it is honored.
Yes, you pick your own MOS. If the MOS you want isn’t available and you don’t like your options, you can walk. You pick your MOS before you take your oath of enlistment. I decided to walk, and while I was waiting for the bus to take me home the recruiter came back and offered a great MOS, and I never regretted taking it.
Now, if you are a screw up and flunk out of your MOS school, “Needs of the Army” is always a possibility. I know some people who didn’t make the cut and they had to pick a new job from a VERY short list.