There are three approaches you could take:
First, and a good choice for minor characters, is not to flesh them out much. Don't describe their clothes. Don't give them a distinct way of speaking or a notable hobby that the text spends time on. In this way, no reader will think "what prosecutor would wear that?" (or say that or do that etc.) Instead they will fill in the clothes, the presumed hobbies and so on from the profession.
Second, make the character odd in some important way. They are from a different country, they are much older or younger than most people in this role, they have survived a life-threatening illness or accident, they are neurodivergent, they are very religious, they have 11 children, they were raised in a commune, whatever. Load them up with mannerisms and hobbies and clothes without putting a lot of thought into it. Do not say that they dress this way because of their time in the Navy. Just describe how they dress. A reader who thinks you are describing clothes far more rigid and formal than someone in that profession usually wears will think the character is sticking to their old dressing habits in the new job. A reader who thinks you are describing clothes far more casual and idiosyncratic than someone in that profession usually wears will think the character is "overcorrecting" from their old dressing habits. If you got the clothes exactly right, no-one will notice, but they may ascribe the unusual hobby to the unusual background, etc.
Third is to learn how people in that profession usually present. At any given moment there are probably a dozen TV shows airing that have significant "prosecutor" characters. Shows about cops, lawyers, scientists who help cops, etc etc all have prosecutors. Take a look at 20 or so of them and work out a common denominator. You will probably find that most of them are in the first group: they have no hobbies, friends, family, or home depicted on screen, meaning that the show is definitely not getting those wrong. Another big chunk will be in the second group because that's either the point of the show or at least the point of the character. But there should be plenty left over who are ordinary. What do they wear? How do they talk? Build up a character who won't appear completely ridiculous to those who have some experience with that profession in real life.
And keep in mind, nobody likes how their professions are portrayed in books and movies. Fictional programmers are terrible representations of programmers, and fictional doctors, lawyers, accountants, chefs, cowboys etc are doubtless no better. It's good that you want to be right, but a lot of people have been very successful without being anywhere near right.