One of my co-workers was ex-Navy, and the "no hands in pockets" thing was really deeply driven into him. Which makes sense, I suppose, when you're living on a ship (a la the old sailing phrase "one hand for yourself, one for the ship.")
The hat, thing, too - I only have experience in context within the military.
Personally, I do think there's something to body language, a la keeping your hands in your pockets. If you're trying to project an image of professionalism and readiness, then that's certainly not going to be a good posture for you. Myself, I've learned over my time in the workplace that small things like this really can make a difference - and it's a habit I had to work at divesting myself of.
Like it or not, as human beings we're constantly picking up on subtle cues and body language and forming opinions when dealing with other people. You literally can't not do it.
I can easily imagine going to a bank to open up a major account (and in this hypothetical I actually had enough money where any of this would matter, of course.) I see two clerks, both dressed in business suits. One is leaning back with his hands in his pockets; the other leaning forward with his hands in plain view. All other things being equal - I'm sure I'd instinctively pick the latter. I might not even necessarily be aware of any particular difference, or even give it any thought. But subconsciously I could easily see myself gravitating towards someone who was projecting the proper body language.