It's their way of getting turned on. The blood vessels in the penis become erected, causing a boner.
Guys can also get boners from waking up in the morning or just being a natural state of comfort that can turn them on, it doesn't always have to be a physical or sexual turn on.
Attention: NOTHING on this site may be reproduced in any fashion whatsoever without explicit consent (in writing) of the owner of said material, unless otherwise stated on the page where the content originated. Search engines are free to index and cache our content. Users who post their account names or personal information in their questions have no expectation of privacy beyond that point for anything they disclose. Questions are otherwise considered anonymous to the general public.