There are several effects that kick in, some you have control over, others you don't.
Writing skill matters
As you ask and answer more questions, typically your skill at writing good questions and answers will improve. Better written posts will get more up votes. This is especially the case with older posts as people find them and up vote them because they are well written.
One will typically also learn how to tailor the post to the audience and be able to engage them through the entire post (which gets more up votes if they read to the end rather than skipping to the next one).
The ability to properly tailor the post to the audience (writing level for beginner or expert - walking through the code or just giving a block) then increases the chances that the answer will be accepted (more on this in a bit). This makes the post the top one seen on the page and also has other nice reputation points boosting side effects (going above the reputation points cap for a day).
More likely to find the post
It is a bit harder on Stack Overflow than other sites, but can still be appreciable when dealing within certain tags. As you write more, your posts will be found more. Getting votes is in part a point of getting views on posts. If you have a few answers on obscure questions you won't get as many as you would if you have more answers on more trafficked questions.
Prefer to answer better questions
FGITW is what it is, but those questions typically disappear into obscurity. The good questions that people answer will get more votes over time than some FGITW answer on a poorly written question. This again goes to the 'more likely to find the post' aspect mentioned previously.
There is also an allure for low reputation points users to post answers in these questions (hoping to catch some of the coattails?). Noting one of my answers on another site, it typically gets a new answer in the post about every other week or so. Having the top voted answer in it, each time that happens I get more reputation points.
Top answers get more votes
If you do have a top answer, it is likely to get more up votes. That's again part of the draw of FGITW. But once you get past that, a well written post at the top may often get another up vote and the second post is less likely to do so. This also plays into the 'writing skill matters' as a well written post is more likely to become a top answer.
People recognize the avatar
Having a non user1234 name with a non-pragmatic avatar will draw eyeballs. Some will recognize you and upvote just because. As you get more recognized within a given community, this will become more prevalent.
Seen as the authority
There are times when if you want to find an answer you may go to that person's profile and search for the keywords and tags you are looking for - noting that they will likely have the best answer out there. For example, someone may do a search such as user:22656 null pointer [java] (note: user 22656 is Jon Skeet) looking for an answer that he gave on null pointers or trying to glean some of the insight he has into the related design issues of null pointers.
Engagement in the site
High reputation points users tend to be more engaged in the site and may go back to review their old posts and fix them. This fixing of old posts will bump it and again, attract eyeballs and votes.
Off site funnels
While it's a lottery, sometimes a well written question and answer will find its way to Reddit, Ars Technica, or Hacker News. Posts in these sites can have long tails of upvotes that continue to provide returns months later from someone finding the post over there. The key is to have something that someone wants to read and follows on to go read it. This requires more than a code dump (and goes back to that writing skill matters bit).
So yes, it does happen for a variety of reasons, and combined they have a positive feedback loop upon up votes and reputation.